a7是获取摇杆角度
class a7{
public chuan=null;
public shou=null;
public run(chuan){
this.shou=chuan;
}
}
下面是子弹类 继承egret.sprite
主类添加子弹图片 timer
constructor(x,y,r)通过这个 传进来 子弹的xy及摇杆角度r
public jiao=null;为了下面的
this.x=Math.cos(this.jiao)*10+this.x;
this.y=Math.sin(this.jiao)*10+this.y;//Math.cos(ang.jieguo)*10
获取角度其中this.x是
class bullet extends egret.Sprite{
public jiao=null
public constructor(x,y,r){ //构造函数。
super(); //继承
var timer6:egret.Timer=new egret.Timer(100,0);
timer6.addEventListener(egret.TimerEvent.TIMER,this.bullet_move,this);
this.jiao=r;
timer6.start();
var enemy:egret.Bitmap = new egret.Bitmap();
enemy.texture = RES.getRes("bg_jpg");
// var bullet_obj=new egret.Shape();
enemy.x=x;
enemy.y=y;
this.addChild(enemy);
// this.bullet_move(); //每创创建一个bullet就移动
}
public bullet_move(){
this.x=Math.cos(this.jiao)*10+this.x;
this.y=Math.sin(this.jiao)*10+this.y;//Math.cos(ang.jieguo)*10
}
}
最后当按钮点击时 新建类将 人物当前xy及角度传给bullet类
function button(){
jiaoo=ang.jieguo;
var aa=new a7();
aa.run(ang.jieguo);
var bu=new bullet(sky.x,sky.y,aa.shou);
this.addChild(bu);
}