This site requires JavaScript, please enable it in your browser!
Greenfoot back
Accir
Accir wrote ...

2019/2/19

Rotating gifs

Accir Accir

2019/2/19

#
Is there a way to rotate a gif when creating player movement?
danpost danpost

2019/2/20

#
Accir wrote...
Is there a way to rotate a gif when creating player movement?
Lack of detail -- not sure what you mean. No code attempt to give context, either.
Accir Accir

2019/2/20

#
I'm trying to rotate a character gif 180 and mirror it when moving to opposite side, but i dont know how to do it with gifs
public void move()
    {
        int x = getX();
        int y = getY();
        if(Greenfoot.isKeyDown("D"))
        {
            setRotation(0);
            x+=STEP;
        }
        if(Greenfoot.isKeyDown("A"))
        {
            setRotation(180);
            Idle.getCurrentImage().mirrorVertically();
            x-=STEP;
        }
        setLocation(x, y);
    }
danpost danpost

2019/2/20

#
Accir wrote...
I'm trying to rotate a character gif 180 and mirror it when moving to opposite side, but i dont know how to do it with gifs
Best would probably be to create 2 GifImage objects and immediately rotate and flip all the images of only one of them for left moving. You will probably then need a GifImage field for the current image set. That is, you will have 3 GifImage fields; one for left images, one for right and one to be set to one of those two for the current set to use for the actor.
You need to login to post a reply.