Hi guys, i’ve got a problem i can’t solve… my problem is: i’ve got some enties of the same kind with the same animation, when i initialize them i set a random frame of the animation. if i debug at the start it’s ok, all different entities start from a random frame of the animation but after a while (some millisecond) they syncronize themselves and i can’t undertand why!
this is my semplified code ( in the reality there are 3 kind of blades with 3 different sprites but the same error result in this semplified exemple too)
import flash.geom.Point; import net.flashpunk.Entity; import net.flashpunk.Graphic; import net.flashpunk.graphics.*; import net.flashpunk.FP;
public class Blade extends Entity
{
[Embed(source = "../../assets/Enemys/lama3.png")]private const BLADE3_IMG:Class;
public var SPRITE_WIDTH:Number ;
public const SPRITE_HEIGHT:Number = 32;
public var ANIMATION_SPEED:Number = 8;
public var BladeSpritemap:Spritemap;
public var currentAnimation:String = "anim";
private var currFrame = 0;
public function Blade(position:Point,bladeType:Number,angle:Number)
{
super();
SPRITE_WIDTH = 96;
BladeSpritemap = new Spritemap(BLADE3_IMG, SPRITE_WIDTH, SPRITE_HEIGHT);
BladeSpritemap.centerOrigin();
BladeSpritemap.add("anim", [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], ANIMATION_SPEED, true);
type = "enemy";
layer = 49;
BladeSpritemap.angle = angle;
if (angle == 0)
{
x = position.x + SPRITE_WIDTH/2 + 32;
y = position.y - 16;
}
else if (angle == 180)
{
x = position.x - SPRITE_WIDTH/2;
y = position.y - 16;
}
setHitbox(0, 0, 0, 0);
//BladeSpritemap.setAnimFrame("anim", FP.rand(15));
BladeSpritemap.play(currentAnimation,false,FP.rand(15));
addGraphic( BladeSpritemap);
}
i tryed ovverriding the update too, remove super() and remove the super from the update… i can0t understand why but in my game all these blade are syncronized…
can anybody help me? Thank’s
PS: sorry for my bad english^^