cocostudio——js 3 final控件事件
来源:互联网 发布:sql写脚本用什么软件 编辑:程序博客网 时间:2024/06/13 09:46
http://www.2cto.com/kf/201410/346470.html
最近试用了下cocos ide,然后引擎用的cocos2dx js 3 final,需要build runtime一下,下面是cocos studio相关的一些事件:
添加事件侦听:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// button
var root = ccs.uiReader.widgetFromJsonFile(
"res/UIButton_Editor/UIButton_Editor_1.json"
);
this
.addChild(root);
var back_label = ccui.helper.seekWidgetByName(root,
"back"
);
back_label.addTouchEventListener(
this
.backEvent,
this
);
var button = ccui.helper.seekWidgetByName(root,
"Button_123"
);
button.addTouchEventListener(
this
.touchEvent,
this
);
var title_button = ccui.helper.seekWidgetByName(root,
"Button_126"
);
title_button.addTouchEventListener(
this
.touchEvent,
this
);
var scale9_button = ccui.helper.seekWidgetByName(root,
"Button_129"
);
scale9_button.addTouchEventListener(
this
.touchEvent,
this
);
// check box
var root = ccs.uiReader.widgetFromJsonFile(
"res/UICheckBox_Editor/ui_checkbox_editor_1.json"
);
this
.addChild(root);
var checkbox = ccui.helper.seekWidgetByName(root,
"CheckBox_540"
);
cc.log(checkbox.addEventListener);
checkbox.addEventListener(
this
.selectedStateEvent,
this
);
// list view
var LISTVIEW_RES = [
"res/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.json"
,
"res/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.json"
];
var root = ccs.uiReader.widgetFromJsonFile(LISTVIEW_RES[
0
]);
this
.addChild(root);
var listView = ccui.helper.seekWidgetByName(root,
"ListView_1214"
);
listView.addEventListener(
this
.selectedItemEvent,
this
);
// page view
var root = ccs.uiReader.widgetFromJsonFile(
"res/UIPageView_Editor/ui_pageview_editor_1.json"
);
this
.addChild(root);
var pageView =ccui.helper.seekWidgetByName(root,
"PageView_1269"
);
pageView.addEventListener(
this
.pageViewEvent,
this
);
// RichText
var richText = ccui.RichText.create();
richText.ignoreContentAdaptWithSize(
false
);
richText.setContentSize(cc.size(
120
,
100
));
var re1 = ccui.RichElementText.create(
1
, cc.color.WHITE,
255
,
"This color is white. "
,
"Helvetica"
,
10
);
var re2 = ccui.RichElementText.create(
2
, cc.color.YELLOW,
255
,
"And this is yellow. "
,
"Helvetica"
,
10
);
var re3 = ccui.RichElementText.create(
3
, cc.color.BLUE,
255
,
"This one is blue. "
,
"Helvetica"
,
10
);
var re4 = ccui.RichElementText.create(
4
, cc.color.GREEN,
255
,
"And green. "
,
"Helvetica"
,
10
);
var re5 = ccui.RichElementText.create(
5
, cc.color.RED,
255
,
"Last one is red "
,
"Helvetica"
,
10
);
var re6 = ccui.RichElementText.create(
7
, cc.color.ORANGE,
255
,
"Have fun!! "
,
"Helvetica"
,
10
);
richText.pushBackElement(re1);
richText.insertElement(re2,
1
);
richText.pushBackElement(re3);
richText.pushBackElement(re4);
richText.pushBackElement(re5);
richText.pushBackElement(re6);
richText.setPosition(cc.p(
1280
/
2
,
720
/
2
));
this
.addChild(richText);
// slider
var root = ccs.uiReader.widgetFromJsonFile(
"res/UISlider_Editor/ui_slider_editor_1.json"
);
this
.addChild(root);
var slider = ccui.helper.seekWidgetByName(root,
"Slider_738"
);
slider.addEventListener(
this
.sliderEvent,
this
);
var scale9_slider = ccui.helper.seekWidgetByName(root,
"Slider_740"
);
scale9_slider.addEventListener(
this
.sliderEvent,
this
);
// text field
var root = ccs.uiReader.widgetFromJsonFile(
"res/UITextField_Editor/ui_textfield_editor_1.json"
);
this
.addChild(root);
var textField_normal = ccui.helper.seekWidgetByName(root,
"TextField_1109"
);
textField_normal.addEventListener(
this
.textFieldEvent,
this
);
var textField_max_character = ccui.helper.seekWidgetByName(root,
"TextField_1110"
);
textField_max_character.addEventListener(
this
.textFieldEvent,
this
);
var textField_password = ccui.helper.seekWidgetByName(root,
"TextField_1107"
);
textField_password.addEventListener(
this
.textFieldEvent,
this
);
各个事件回调:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// widget
touchEvent: function (sender, type) {
switch
(type) {
case
ccui.Widget.TOUCH_BEGAN:
cc.log(
"Touch Down"
);
break
;
case
ccui.Widget.TOUCH_MOVED:
cc.log(
"Touch Move"
);
break
;
case
ccui.Widget.TOUCH_ENDED:
cc.log(
"Touch Up"
);
break
;
case
ccui.Widget.TOUCH_CANCELED:
cc.log(
"Touch Cancelled"
);
break
;
default
:
break
;
}
},
// check box
selectedStateEvent: function (sender, type) {
switch
(type) {
case
ccui.CheckBox.EVENT_SELECTED:
cc.log(
"Selected"
);
break
;
case
ccui.CheckBox.EVENT_UNSELECTED:
cc.log(
"Unselected"
);
break
;
default
:
break
;
}
},
// list view
selectedItemEvent: function (sender, type) {
switch
(type) {
case
ccui.ListView.EVENT_SELECTED_ITEM:
var listViewEx = sender;
cc.log(
"select child index = "
+ listViewEx.getCurSelectedIndex());
break
;
default
:
break
;
}
},
// page view
pageViewEvent: function (sender, type) {
switch
(type) {
case
ccui.PageView.EVENT_TURNING:
var pageView = sender;
cc.log(
"page = "
+ (pageView.getCurPageIndex() +
1
));
break
;
default
:
break
;
}
},
// slider
sliderEvent: function (sender, type) {
switch
(type) {
case
ccui.Slider.EVENT_PERCENT_CHANGED:
var slider = sender;
var percent = slider.getPercent();
cc.log(
"Percent "
+ percent.toFixed(
0
));
break
;
default
:
break
;
}
},
// text field
textFieldEvent: function (sender, type) {
switch
(type) {
case
ccui.TextField. EVENT_ATTACH_WITH_IME:
cc.log(
"attach with IME"
);
break
;
case
ccui.TextField. EVENT_DETACH_WITH_IME:
cc.log(
"detach with IME"
);
break
;
case
ccui.TextField. EVENT_INSERT_TEXT:
cc.log(
"insert words"
);
break
;
case
ccui.TextField. EVENT_DELETE_BACKWARD:
cc.log(
"delete word"
);
break
;
default
:
break
;
}
}
0 0
- cocostudio——js 3 final控件事件
- cocostudio——js 3 final控件事件
- Cocostudio控件
- cocos2d-x 2.2.2 中cocostudio控件TouchGroup触摸事件
- js cocostudio中动画帧事件的使用
- Cocos2d-JS项目之二:cocostudio基础控件的使用
- ASP.NET-008—JS绑定控件事件
- Cocostudio常用控件
- CocoStudio中的一些控件
- cocos2dx & cocostudio 控件构想
- Cocos2d-x教程 CocoStudio篇 (3) UICheckBox 复选框控件
- cocos2d-x 界面编程二(cocostudio GUI的控件事件响应)
- Cocostudio touch事件传递机制
- cocostudio 事件穿透(coco2dx 3.2)
- Cocostudio按钮事件不能响应
- cocoStudio: button触摸事件响应
- JS——事件
- js——事件
- 05-lucene高级搜索
- Java实现各式各样的9*9乘法表
- Android—Activity之间的切换动画——overridePendingTransition(0, 0);
- Jinja架构下,运行view.py时出现找不到指定文件的问题
- Android中滑屏实现----手把手教你如何实现触摸滑屏以及Scroller类详解
- cocostudio——js 3 final控件事件
- 关于tableViewCell重用的问题
- DHTML之事件处理
- eclipse的调试
- TDA7419调试记录(1)——2015/04/17
- Cursorlei
- 常量和指针
- 关于zTree的使用心得以及相关的JS技术总结
- 考试