Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

怎么销毁一个预制物体生成的物体

$
0
0

@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

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles