cocos2d js 關於多端文字輸入框問題

2021-08-06 06:20:01 字數 1390 閱讀 9717

this.editbox2 = new cc.editbox(cc.size(200, 30), new cc.scale9sprite(res.imgbox));

this.editbox2.x = cc.winsize

.width / 2

;this.editbox2.y = cc.winsize

.height / 2

;this.editbox2.setinputmode(cc.editbox_input_mode_singleline); // 設定輸入模式

this.editbox2.setreturntype(cc.keyboard_returntype_done); // 返回值型別

this.editbox2.setdelegate(this); // 繫結父級

this.editbox2.setinputflag(cc.editbox_input_flag_password); // 輸入型別

this.editbox2.setmaxlength(21); // 輸入字元個數

this.editbox2.setplaceholderfontcolor(cc.color(229,221,218)); // 提示文字顏色

this.editbox2.setplaceholder("6到14位字母或者數字"); // 提示文字內容

結果如圖:

var text = new ccui.textfield();

text.setmaxlengthenabled(true);

text.setmaxlength(4);

text.settouchenabled(true);

text.fontname = "marker felt"

; text.fontsize = 30

; text.placeholder = "please input your words here"

; text.x = cc.winsize

.width / 2

; text.y = cc.winsize

.height / 2

; text.addeventlistenertextfield(this.textfieldevent, this);

this.addchild(text);

Cocos2d JS螢幕適配

有終端開發經驗的讀者應該對螢幕適配問題深感痛惡,因為這個世界實在有太多型別的手機和平板了,各種尺寸 首先,我們來認識三個術語 cocos2d js為我們提供的螢幕適配方法有如下幾種 1.自適應拉伸cc.resolutionpolicy.exact fit 該方案下,遊戲剛好鋪滿整個螢幕,但畫面的比例...

cocos2d js環境搭建

一 環境配置 1.安裝python2.7x版本 二 建立工程 mac版本 命令 setup.py 配置當前cocos2dx mac上的環境變數 windows版本 命令 cocos new 工程名 p 包名 l js cpp android d 工程儲存路徑 三 了解引擎或者工程的結構目錄 配置好基...

cocos2d JS 專案結構

初次建立並開啟乙個 cocos creator 專案後,您的專案資料夾將會包括以下結構 projectname 專案資料夾 assets library local settings temp project.json下面我們將會介紹每個資料夾的功能。assets將會用來放置您遊戲中所有本地資源 指...