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

2018/12/13

Gravity doesn't work

1
2
danpost danpost

2018/12/13

#
CoolSharkCody wrote...
Also I added another addObject(new FishMan) command as a backup because the actors were showing up at the wrong times, and the FishMan actor was always showing up whenever the TitleScreen actor appeared, even when I changed its code in MyWorld.
Ah, so you want the TitleScreen object to do its animation, then go away while, at the same time, the FishMan object is added to the world. Correct? Another question: why do you add your Background1 object near the top of your world? Is that not supposed to be like a ground for your fishman to stand on?
CoolSharkCody CoolSharkCody

2018/12/13

#
Yeah. Also the Background1 image has a platform near the bottom of the screen, and the image is huge, so I had to center it in order for it to be perfectly alligned in the world.
danpost danpost

2018/12/13

#
CoolSharkCody wrote...
Yeah. Also the Background1 image has a platform near the bottom of the screen, and the image is huge, so I had to center it in order for it to be perfectly alligned in the world.
That is the problem then -- the image is huge -- probably takes up the entire world. So, the onGround method will always return true. Meaning VSpeed will be -16 for every act step the "up" key is pressed (which, will usually be 3 to 4 act steps for a fairly quick pressing of the key). Maybe you should add a new actor to be the ground (even if its image is transparent). The image should be as wide as the world and maybe 40 pixels high. The actor should be centered horizontally in the world and placed near the bottom of it, top edge of image aligned with top edge of platform in image of Background1 object. Also, you may just want to draw the image you are using for the Background1 object onto the background image of the world and dispense with the Background1 object (and class).
CoolSharkCody CoolSharkCody

2018/12/13

#
I’ll try to add a new actor and see if that works soon.
CoolSharkCody CoolSharkCody

2018/12/14

#
It worked. Thanks!
You need to login to post a reply.
1
2