分析飞机敌机的技巧-2

来源:互联网 发布:通用数据采集软件 编辑:程序博客网 时间:2024/05/23 15:34

  敌机是随机的反方向随机出现的,给敌机添加个敌机精灵.类去实现敌机的基本功能,并且给他附加个消除功能+循环随机出现

 

var Enemy = cc.Sprite.extend({    ctor: function () {        this._super(敌方飞机图片);    }});
 
var EnemyLayer = cc.Layer.extend({    ctor: function () {        this._super();        this._init();        this.schedule(this._init, 1, cc.repeatForever, 1);    },    _init:function() {        var difan = new Enemy();        difan.setPosition(cc.winSize.width*Math.random(),cc.winSize.height);        var moveTo = cc.moveBy(6, cc.p(0,-cc.winSize.height+20));        difan.runAction(cc.sequence(moveTo, cc.callFunc(this.removeBullet, this)));        this.addChild(difan)    },    removeBullet:function(target){        target.removeFromParent(true)    }});

 

 

0 0
原创粉丝点击