1.事件,
TouchOneByOneTest,
TouchAllAtOnce,
AccelerometerTest,
MouseTest,
KeyboardTest
2. 加入监听
if( 'touches' in cc.sys.capabilities ) {
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: true,
onTouchBegan: this.onTouchBegan,
onTouchMoved: this.onTouchMoved,
onTouchEnded: this.onTouchEnded,
onTouchCancelled: this.onTouchCancelled
}, this);
if( 'touches' in cc.sys.capabilities ) {
// this is the default behavior. No need to set it explicitly.
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesBegan: this.onTouchesBegan,
onTouchesMoved: this.onTouchesMoved,
onTouchesEnded: this.onTouchesEnded,
onTouchesCancelled: this.onTouchesCancelled
}, this);
if( 'accelerometer' in cc.sys.capabilities ) {
// call is called 30 times per second
cc.inputManager.setAccelerometerInterval(1/30);
cc.inputManager.setAccelerometerEnabled(true);
cc.eventManager.addListener({
event: cc.EventListener.ACCELERATION,
callback: function(accelEvent, event){
if( 'mouse' in cc.sys.capabilities ) {
cc.eventManager.addListener({
event: cc.EventListener.MOUSE,
onMouseDown: function(event){},
onMouseMove: function(event){}
onMouseUp: function(event){}
if( 'keyboard' in cc.sys.capabilities ) {
cc.eventManager.addListener({
event: cc.EventListener.KEYBOARD,
onKeyPressed:function(key, event) {
cc.log("Key up:" + key);
},
onKeyReleased:function(key, event) {
cc.log("Key down:" + key);
}
}, this);
3
var fontList = [
// System Fonts
"Verdana",
"Lucida Sans Unicode",
"Bookman Old Style",
"Symbol",
"Georgia",
"Trebuchet MS",
"Comic Sans MS",
"Arial Black",
"Tahoma",
"Impact",
// custom TTF
"American Typewriter",
"Marker Felt",
"A Damn Mess",
"Abberancy",
"Abduction",
"Paint Boy",
"Schwarzwald",
"Scissor Cuts"
];