Hi There,
I'm having a problem with a class I developed to handle all my sprites.
I've set up a *Sprite Factory*.
In it are all the sprite objects and methods to iterate though the animations and return the correct frames.
The code looks like this:
So, in the above code the sprite (called "player") is supposed to update it's image for every call of Act(); then the Player Object requests the current image from the SpriteFactory, which then returns the current image from the sprite class to the player object.
This doesn't happen. The sprite class doesn't update the image at all, even though the correct method is called in the SpriteFactory's Act() method.
However, if I move the method call for updating the sprite image into the getPlayerImage() method, everything updates fine.
Anyone got any ideas why this is the case?
Why will the Act method not update the sprite image even though the correct method call is in there?
thanks,
Paul.
public SpriteFactory() { building = new Sprite("Terrain", 6); specialWeapon = new Sprite("specialWeapon", 4); player = new Sprite("playerTest",5); } public void act(){ updateAllSprites(); } private void updateAllSprites(){ player.updateSprite(); } public GreenfootImage getPlayerImage(){ return player.getImage(); }