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

2012/11/23

Teleport on maze game

X32_PAFC X32_PAFC

2012/11/23

#
Hi all I would like my character to be teleported around the maze, when he reaches a certain point...any ideas?
Zamoht Zamoht

2012/11/23

#
if (foundWhatEverYouWantMeToFind()) { setLocation(x, y); }
danpost danpost

2012/11/23

#
Do you have objects at the locations where the teleporting begins and ends (or, what lets the user know that their actor will be teleported at that point)? Do you only have one set of teleporting objects at a time (if any)?
X32_PAFC X32_PAFC

2012/11/24

#
i have orbs at each end of the teleport but cant find a method to make my character transport
Zamoht Zamoht

2012/11/24

#
setLocation(orbObjectToTeleportTo.getX(), orbObjecttoTeleportTo.getY(); This will teleport you to the orbObjectToTeleportTo object, but you might judt call it orb. So make sure to have a reference to the object you wanne teleport to.
danpost danpost

2012/11/24

#
Instead of trying to find code, try creating it. You already know that - if actor touches orb, transport and transporting involves - find out location of other orb - move actor to that location The one problem you might encounter is if you allow two-way transporting, you will need some way of preventing the actor from returning immediately after arriving at an orb (the actor would repeatedly jump back and forth between the two orbs). The way to prevent it is to check if the actor has moved off the orb it has arrived at. An instance boolean can be used to indicate that transport was executed and you are now waiting for the actor to move off of the orb (at which point the boolean value should be reset).
danpost danpost

2012/11/24

#
You may want to take a look at the code of my Teleport Demo.
X32_PAFC X32_PAFC

2012/11/24

#
thank you, this has been helpful :)
You need to login to post a reply.