Help with this issue

Subscribe to Help with this issue 3 posts

avatar for Shadow_Craver Shadow_Craver 344 posts
Flag Post

I want my character to teleport to the mouse’s location after pressing Space then clicking the mouse. I have successfully done this without the use of clicking.

onEnterFrame = function ():Void {
	if (Key.isDown(Key.SPACE)){
_root.char._x=_root._xmouse
_root.char._y=_root._ymouse
	}
}

How do I make it so that I have to click after I press space? And if I press space twice it cancels the teleport completely?

 
avatar for UnknownGuardian UnknownGuardian 8141 posts
Flag Post

Have a timer checking how long since the last press of SPACE. If within 45 frames or something that the user clicks, then teleport the character.

 
avatar for Ace_Blue Ace_Blue 1089 posts
Flag Post

Or, if you want to allow the player to think long and hard about where they want to teleport, set a Boolean flag to true when the space key is released. When the mouse left button is clicked, check the flag. If it’s true, set it to false and teleport the character, otherwise do what you normally do when the player clicks the mouse.