@754141166 写道:
cc.Class({
extends: cc.Component,properties: { ballPrefab:{ default:null, type:cc.Prefab } }, // use this for initialization zxy:function(){ var self = this; var listener = { event:cc.EventListener.KEYBOARD, onKeyPressed:function(keyCode,event) { if(keyCode==cc.KEY.q) { var newBall = cc.instantiate(self.ballPrefab); self.node.addChild(newBall); newBall.setPosition(cc.p(50,50)); } if(keyCode==cc.KEY.e) { this.newBall .destroy(); } }, } cc.eventManager.addListener(listener, this.node);
},
onLoad: function () { this.zxy(); }, // called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
帖子: 1
参与者: 1