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

2019/3/12

Platform Problems

1
2
danpost danpost

2019/3/15

#
SymInvader wrote...
So how would I get it to detect the side of the platform? I know I have to include "getOneObjectAtOffset()", but I'm not sure about how to use it.
I hardly ever use getOneObjectAtOffset or getObjectsAtOffset. I do the following steps: (1) determine direction to move; (2) move; (3) check collision with getIntersectingObjects; (a) if found (list returned is not empty), move back off of any an all obstacles; (b) if not found, do nothing (no code required for this step); Step one should take into consideration both directions along the axis. An local int field, initialized to zero, can be set up to retain the direction. Add one to it if the positive direction is indicated and subtract one if the other direction is. Both or none could also be indicated, so its final value will be -1, 0 or 1. This value is used to set the new location in step 2 and could be multiplied by a positive speed value. Its sign can be used in determining where to relocate the actor in step 3a if it ends up touching an obstacle after the initial move.
SymInvader SymInvader

2019/3/15

#
Tried it out and it works now. Thanks for the help! :)
You need to login to post a reply.
1
2