Game Development Community

Button pressed/held/released

by Paul Bellezza · in Torque X 2D · 10/13/2007 (5:48 pm) · 1 replies

Hey guys, I'm working on adding in a power for my player character that would be activated by a key press, and remain active as long as the player is holding down the button/key, ending when they release the key/button.

I also want the power to be able to track a few pieces of information while it is active (primarily the player characters current position for that frame).

I figured out how to add another power and it activates when I press the key, but how do I make it remain active for as long as the key is down? I based the code off the glide mechanic of from the platformer starter kit.

Secondly, what would be a good way of tracking the players position on each frame? I want to be able to create a small list of tracked positions for usage. My intuition is to create another class with the data structures for this, but I'm not sure how to communicate my current position to this class (actor._actor.Position?) and how to make sure this is done every frame until the player releases the key.

Pointers to the right places to look would be greatly appreciated.

FWIW I have added code to ActorController, ActorComponent, PlayerController and DragonActorComponent to get the initial stuff going, I really just don't know how to communicate my current position and how to do this every frame.

#1
10/14/2007 (7:57 pm)
Update, I figured out some of this. I am able to store the current position of my character on a button press, however my hope is to make it keep "recording" as long as the button is held down.

The other thing is, I'm not sure what a good methodology would be for tracking my characters state during recording. I'm making my changes/additions in actorcomponent.cs, but I don't seem to have scope access to the players current animation state in the spot where I'm making changes...