var my_plane = cc.Sprite.extend({
_lx: null,
_hp: null,
_tim:null,
_canatt:true,
init: function (pp,lx,hp) {
var bRef = false;
if (this._super(pp)) {
//this.steupView(res.fly_png);
this._lx=lx;
this._hp=hp;
this._tim=0;
bRef = true;
}
this.schedule(this.sss,2);
if (lx!=1){
}
return bRef;
},
sss:function(){
//cc.log("hh");
}
});
my_plane.create = function (pp,lx,hp) {
var ly = new my_plane();
if(ly && ly.init(pp,lx,hp)){
return ly;
}
return null;
};
var size = cc.winSize;
cc.spriteFrameCache.addSpriteFrames(res.em_plane_plist);
//用这些代码没问题
//var f_sp_1 = new cc.Sprite("#s2.png");
//f_sp_1.attr({
// x: size.width /2,
// y: size.height/2
// });
//this.addChild(f_sp_1,2);
//改成下面代码,图片不显示,程序也不报错
var em_fly = my_plane.create("#s2",2,1);//(res.fly_png,2,1);//new cc.Sprite(res.fly_png);//类型,hp
em_fly.attr(
{
x: Math.random()*cc.winSize.width,//size.width /2,
y: cc.winSize.height,//cc.size.height,
//scale:0.3,
rotation:180
});
this.addChild(em_fly,2);