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

2014/11/25

How to make an actor stay on ground with no platforms

cloud41910 cloud41910

2014/11/25

#
Hi, I've been watching tutorials about making an actor jump and fall and stay with a platform but how do i make my actor to stay on ground with no platforms this video http://youtu.be/fCsMiiup1OQ solved my problem but the codes are blurr can somebody clear the codes for me i've set it to HD and still the codes aren't clear
danpost danpost

2014/11/26

#
By ground with no platform, I presume you mean the bottom edge of the world window which has a y-coordinate value of one less than the height of the world -- 'getWorld().getWidth()-1'. To keep your actor 'on' the edge (without half of the image of the actor 'below' that edge) you must account for the height of the image of your actor. The y-coordinate of your actor is half way between the top and bottom edge of its image. Therefore, if we ensure that the y-coordinate of your actor does not exceed 'getWorld().getHeight()-1-getImage().getHeight()/2', then you are home free. In short, if the y-coordinate of your actor exceed that value, set it to that value.
cloud41910 cloud41910

2014/11/28

#
I've already did it and also i've got another thread on how to apply the healthbar to my shooting game please help I'm new in greenfoot and my prof didn't teach us anything about this
You need to login to post a reply.