public Animation(string[] files, SpriteObj animationOwner, float fps, bool loop = true) { Loop = loop; IsPlaying = true; numFrames = files.Length; owner = animationOwner; sprites = new Sprite[numFrames]; for (int i = 0; i < sprites.Length; i++) { sprites[i] = new Sprite(files[i]); } owner.SetSprite(sprites[0]); if (fps > 0.0f) { frameDuration = 1 / fps; } else { frameDuration = 0.0f; } }
public void Update() { fpsCounter -= GfxTools.Win.deltaTime; if (isPlaying && fpsCounter <= 0) { fpsCounter = 1 / fps; //fps al secondo? cosa serve? 1/30 significa 30 animazioni in un secondo??? 1/2 fa due animazioni al secondo if (currentIndex >= sprites.Length) { OnAnimationDeads(); } owner.SetSprite(sprites[currentIndex++]); } }
public void Update() { if (owner != null && IsPlaying) { if (frameDuration != 0.0f) { counter += GfxTools.Win.deltaTime; if (counter >= frameDuration) { counter = 0; currentFrame = (currentFrame + 1);// % numFrames; } } else { owner.SetSprite(sprites[currentFrame]); } } }