Home > other >  CreateJS Spritesheet (Sprite figure use issues)
CreateJS Spritesheet (Sprite figure use issues)

Time:09-25


As shown in figure of the two things are the Bomb inside the game, they are my type of Bomb the instantiation of the object, but there is A problem, suppose I new bombs on stage, A new Bomb B again, also is as the following:
Main. Js file:
 
Var noBrain=new Bomb (" noBrain ");
GameView. AddChild (noBrain);
Var noHappy=new Bomb (" noHappy ");
GameView. AddChild (noHappy);


Class defined Bomb Bomb. Js file () :
 
The function Bomb (type) {
Enclosing buildBomb (type);
}
Bomb. The prototype=new createjs. Container ();
Bomb. Prototype. Mbody=new createjs. Sprite ();

Bomb. Prototype. BuildBomb=function (a type) {
The switch (type) {
Case "nohappy" :
Var spritesheet=new createjs. Spritesheet ({
"Images" : "./img/mainPage/character_1 PNG "],
"Frames" : {
"Height" : 313,
"Count" : 10,
"Width" : 277
},
Framerate: 30,
Animations: {
Stand: 0,
Run0: [0, 9],
}
});
Enclosing Mbody=new createjs. Sprite (spritesheet, 'run0');
Enclosing Mbody. GotoAndPlay (parseInt (Math) floor (Math) random (10)));
break;
Case "nobrain" :
Var spritesheet=new createjs. Spritesheet ({
"Images" : "./img/mainPage/character_2 PNG "],
"Frames" : {
"Height" : 560,
"Count" : 10,
"Width" : 284
},
Framerate: 30,
Animations: {
Stand: 0,
Run0: [0, 9],
}
});
Enclosing Mbody=new createjs. Sprite (spritesheet, 'run0');
Enclosing Mbody. GotoAndPlay (parseInt (Math) floor (Math) random (10)));
break;
Default:
break;
}
Enclosing addChild (enclosing Mbody);
}


Can appear such circumstance, I don't know whether I SpriteSheet (elf), strives for the great god teach,,,
(random @ the system recommended by five great god, and if there is disturbed, the next here with a not T - T)

CodePudding user response:

Great god teach ~ @ lanix516 o

CodePudding user response:

And the speed of the elves, with this new Bomb class increases with the double objects, and the new one object increased one times, the new increase two times, the new three increased three times, no matter the constructor are introduced into the type of "nobrain" or "nohappy ~ ~"

CodePudding user response:

Is drawing objects, the elves of cumulative mapping problem ~ did you see the two objects overlap
  • Related