cocosjs 触摸

时间:2023-12-20 23:38:20
/**
* Created by sun on 15/11/24.
*/ var Piece = cc.Sprite.extend({
ctor:function (num)
{
this._super();
if(num==0)
{
this.initWithFile(res.piece_00_png);
}
else if(num==1)
{
this.initWithFile(res.piece_01_png);
}
else if(num==2)
{
this.initWithFile(res.piece_02_png);
}
else
{
this.initWithFile(res.piece_03_png);
} cc.eventManager.addListener({
event : cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches : false,
onTouchBegan : this.onTouchBegan,
onTouchMoved : this.onTouchMoved,
onTouchEnded : this.onTouchEnded },this); return true;
}, onTouchBegan :function(touch ,event)
{
var touches =touch.getLocation();
if(touches){
//cc.log("touches");
}
return true;
},
onTouchMoved : function(touch ,event)
{
cc.log("hello");
},
onTouchEnded :function(touch ,event){
cc.log("world");
} });