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

2016/1/15

Actor turning left/right issue. Please help!

Dovy33 Dovy33

2016/1/15

#
My actor moves one direction facing it and other (left) backwards. I want to make it face left when he moves there and right as well. Please help ;( if (Greenfoot.isKeyDown("d")) { move(2); } if (Greenfoot.isKeyDown("a")) { move(-2); }
danpost danpost

2016/1/15

#
You need to create two fields for the left- and right-facing images and assign the appropriate one when moving. At least one of the images is usually read from an image file in the file directory. The other one can also be read in or can be created by way of mirroring a copy of the first image.
Dovy33 Dovy33

2016/1/16

#
I have to mirrored images, but I dont really understand what you mean by two fields. Can you show me by commands or something. I started programing not a log ago...
Dovy33 Dovy33

2016/1/16

#
And I also dont know how to make actor stand on the floor, not fall through it...
danpost danpost

2016/1/16

#
Dovy33 wrote...
I have to mirrored images, but I dont really understand what you mean by two fields. Can you show me by commands or something. I started programing not a log ago...
I was referring to object reference fields which is discussed here in the java tutorials. Near the end of the page, there is a short note on Types. It really does not specifically get into object reference types; but, just like primitive types like 'private int cadence;', you can have reference types like 'private GrenfootImage imageLeft;'.
And I also dont know how to make actor stand on the floor, not fall through it...
This is a bit more involved. Basically, do the following each act cycle -- move and, if intersection floor, move back.
Dovy33 Dovy33

2016/1/17

#
Thanks very much with mirrored images, it worked! But I still don't really understand the intersection...
You need to login to post a reply.