34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
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;
|
|
}
|
|
}); |