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

2017/3/30

Face Direction

rockon411 rockon411

2017/3/30

#
How would I go about making an actor face west by default when it is placed in the world?
danpost danpost

2017/3/30

#
rockon411 wrote...
How would I go about making an actor face west by default when it is placed in the world?
Show the code you currently have for the actor. Also, should the rotation of the actor remain zero when facing left?
rockon411 rockon411

2017/3/30

#
I don't have much and yes I believe so.
1
2
3
4
5
6
7
8
9
10
11
import sofia.micro.*;
 
public class Minnow extends Fish
{
    public Bee()
    {
    }
    public void move()
    {
        super.move(.0125);
    }
danpost danpost

2017/3/30

#
danpost wrote...
should the rotation of the actor remain zero when facing left?
rockon411 wrote...
yes I believe so
Do you have an image for the minnow facing left? Oh, and it will still turn around and face right at times -- correct? -- so you will need two images?
rockon411 rockon411

2017/3/30

#
Realistically it never needs to turn, but I don't really know what you mean by the images.
danpost danpost

2017/3/30

#
The 'move' method is dependent on the rotation of the actor. If you do not rotate the actor and give it a left-facing image, a positive movement will cause the actor to move backwards (to the right, which is the along the zero rotational degree line). If you rotate the actor 180 so that forward is to the left, then its image will be upside down. Would you mind the image being upside down? or would you rather rotate the actor AND change its image so that it is upside up when facing left?
rockon411 rockon411

2017/3/30

#
Wow I think I'm learning more on this website than I am in class. I would not mind it being upside down at all.
danpost danpost

2017/3/30

#
Btw, the code you gave could not possibly compile. You have a Bee constructor in a Minnow class. That will never work. So, is it a Minnow class? or, is it a Bee class?
rockon411 rockon411

2017/3/30

#
Shoot. Sorry I keep using different codes from different programs I have worked on. It is a minnow class.
danpost danpost

2017/3/31

#
Replace lines 5 through 7 in the Minnow class with:
1
2
3
4
public Minnow()
{
    setRotation(180);
}
You need to login to post a reply.