init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
properties: {
|
||||
liziNodeChild: {
|
||||
default: null,
|
||||
type: cc.ParticleSystem,
|
||||
displayName: "粒子效果"
|
||||
}
|
||||
},
|
||||
start: function () {
|
||||
cc.game.addPersistRootNode(this.node);
|
||||
this.node.zIndex = cc.macro.MAX_ZINDEX;
|
||||
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
|
||||
this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
||||
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||
this.node._touchListener.swallowTouches = false;
|
||||
},
|
||||
onTouchStart: function (e) {
|
||||
this.startPos = this.node.convertToNodeSpaceAR(e.getLocation());
|
||||
this.liziNode = cc.instantiate(this.liziNodeChild.node);
|
||||
this.liziNode.parent = this.node;
|
||||
this.liziNode.zIndex = cc.macro.MAX_ZINDEX;
|
||||
this.liziNode.getComponent(cc.ParticleSystem).resetSystem();
|
||||
this.liziNode.position = this.startPos;
|
||||
},
|
||||
onTouchEnd: function () {
|
||||
this.liziNode.getComponent(cc.ParticleSystem).stopSystem();
|
||||
},
|
||||
onTouchMove: function (e) {
|
||||
this.startPos = this.node.convertToNodeSpaceAR(e.getLocation());
|
||||
this.liziNode.position = this.startPos;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user