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

What is happening right now?

RcCookie

reply to Stopping Objects

By RcCookie - about 3 hours ago
I was assuming that you wall class is called „Wall“. Otherwise you have to change line 6.
danpost

reply to help plz

By danpost - about 4 hours ago
mik. wrote...
<< Codes Omitted >> Which is better???
If the rock is affected by the collision in any way (direction, velocity, damage, image, etc.) or for some reason needs recorded as being the last one collided with, the first will be required. If there is no change to the rock (or it only needs removed from the world), there is no need to reference it and the second will suffice.
RcCookie

reply to Help

By RcCookie - 1 day ago
mik. wrote...
I think you are not able to understand Sorry for my poor grammars I apologise Let us take an example If i hold the enter key down the obj moves And when i release the enter key the obj stops moving. Like that only when i hold the mouse button down obj will start moving and when i release the mouse button (up) it should stop moving automatically like the enter key If i am not wrong i think your code will only stop the obj when the mouse pressed null I want obj to stop moving automatically when the mouse button is released
You are wrong ;-) What you propably don't know is that Greenfoot.mousePressed() is only true in the one frame the mouse switched from a non-pressed state to a pressed state. Same goes for Greenfoot.mouseClicked(): it is ONLY true in the one frame there the mouse was released. If no change to the mouse state happens, the old moving state will not be changed - if it stood still, it will stand still again, if it moved it will do so again.