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

2021/2/28

How to adress one kind of actor

Znarf Znarf

2021/2/28

#
So im programming snake rn and every part the snake is a different actor. I've got three classes, snakehead, snaketail and snakebody. the head is always faster as the body and the tail is always slower. If u look at it step by step everythings fine but when you ran it the animation looks like head and tail are off. Is their a way to synchronize their movement, so that they all move at the same time. I thought mabey you could just make a method that moves every snakehead every tail and every body. But idk how to adress all objects of a class.
RcCookie RcCookie

2021/2/28

#
If you want all objects of a class from a giver World world, you can use
world.getObjects(SnakeHead.class);
However I don’t think this will fix any problem. That’s because every segment of the snake will always move at the same speed.
Znarf Znarf

2021/3/1

#
I want them to move at the same speed. The problem is that the head performs the move action before the body and only then the tail does. This causes the animation to look like the head is detached although it isn't. It#s a bit hard to explain but the scenario is on my profile if you wanna look for yourself If I wanna use world.getObjects(SnakeHead.class); how do I then make them perform the move action?
danpost danpost

2021/3/1

#
Did you try using the setActOrder method?
You need to login to post a reply.