Making a direction controller
IntelligentDesigner
Member Posts: 517
I am making a directional controller, and have an integer attribute called "game.direction" When "UP" is pressed I make it 12, "DOWN" is 6, "RIGHT" is 3, and "LEFT" is 9, (like a clock).
I have an actor that I want to control with this controller, so I added a rule to that actor that runs if the game.direction = 12, etc. As soon as the button at the controller is pressed ("UP" in this example) I get uncontrolled "UP" movement (not like when the keyboard "up" key was pressed, nicely moving one unit at a time.)
I have the same rule reset game.direction attribute to 0 in the same logic that does the UP.
How can I get one and only one "UP" per touch on the controller? I want it to behave like the keyboard did, one step per click...
Thanks in advance for any suggestions, GSers...
I have an actor that I want to control with this controller, so I added a rule to that actor that runs if the game.direction = 12, etc. As soon as the button at the controller is pressed ("UP" in this example) I get uncontrolled "UP" movement (not like when the keyboard "up" key was pressed, nicely moving one unit at a time.)
I have the same rule reset game.direction attribute to 0 in the same logic that does the UP.
How can I get one and only one "UP" per touch on the controller? I want it to behave like the keyboard did, one step per click...
Thanks in advance for any suggestions, GSers...
Comments
Thanks for the thought though...
Good luck
I am still working at it, thinking perhaps it is a timing issue, and maybe a timer pausing it till the attributes have a chance to reset themselves may help...
Attributes: game.up game.down game.left game.right
now, I am assuming you will have 4 actors for the arrow keys for touch.
I will name them Left, Right, Up, and Down
Here are the rules for them:
Left
--- Rule; when actor recieves touch change attribute game.left to true
-----Otherwise; change attribute game.left to false
Right
--- Rule; when actor recieves touch change attribute game.right to true
-----Otherwise; change attribute game.right to false
Up
--- Rule; when actor recieves touch change attribute game.up to true
-----Otherwise; change attribute game.up to false
Down
--- Rule; when actor recieves touch change attribute game.down to true
-----Otherwise; change attribute game.down to false
-----------------------------------------------------------------------------------------------
Now this code is for your actor/player/movable object;
--Rule; when attribute game.up is true accelerate up (I'm not on my mac so I'm not sure what the angle is off the top of my head)
Now do this for all of the other attributes game.down, game.left, and game.right
I think this should work.
If it doesn't work, then do this in the player movement for the arrow keys: --Rule; when attribute game.up is true accelerate up (I'm not on my mac so I'm not sure what the angle is off the top of my head)
----(added part) Otherwise accelerate up at ZERO speed
Hope it works!!
~CTM
Previously I had a rule that if the length was exceeded, to destroy the oldest actor, as measured by his ActorID. This logic no longer works when the control is switched to touch, instead of keyed.
Can anyone help to explain why?
Remember: in this case the actor is moved my SPAWNING,*not*
Move or move to.
apparently there is a huge bug here.