Cocos2d-x《雷电大战》(3)-子d无限发射

Cocos2d-x《雷电大战》(3)-子d无限发射,第1张

概述Cocos2d-x《雷电大战》(3)-子d无限发射 作者想让飞机能发子d 1 资源  var res = {///.... BULLET1:'res/bullet1.png',//..... }; 2 有调度的airplane var Airplane = cc.Layer.extend({ ctor:function (){//...... me.batchNo

Cocos2d-x《雷电大战》(3)-子d无限发射


作者想让飞机能发子d

1 资源

var res = {///....  BulLET1:'res/bullet1.png',//.....  };

2 有调度的airplane
var Airplane = cc.Layer.extend({    ctor:function (){//......      me.batchNode=new cc.SpriteBatchNode(res.BulLET1);      me.batchNode.retain();      me.bullteID=0;      me.bullteSpeed=500;      me.bulltes={};      me.schedule(me.fire,0.5);//......      return true;    },onExit:function(){      me.batchNode.release();    },fire:function(dt){      var me=this;      var sp=new cc.Sprite(me.batchNode.getTexture());      var point=me.air.getposition();      var px=point.x;      var py=point.y + me.air.getContentSize().height + 20;      sp.setposition(px,py);      var bID=me.bullteID++;      sp.setTag(bID);      me.addChild(sp,-1);      var flyLen= cc.winSize.height - py;      var duration = flyLen / me.bullteSpeed;      var action=new cc.Sequence([        new cc.Moveto(duration,cc.p(px,cc.winSize.height)),new cc.CallFunc(function(bullet,ID){          delete this.bulltes[ID];          this.removeChildByTag(ID);        },me,bID)      ]);      sp.runAction(action);      me.bulltes[bID]=sp;    }});
总结

以上是内存溢出为你收集整理的Cocos2d-x《雷电大战》(3)-子d无限发射全部内容,希望文章能够帮你解决Cocos2d-x《雷电大战》(3)-子d无限发射所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1084305.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存