Need help with joystick controls
i'm trying to make a joystick but keep it from sliding all over the screen but its not working. Can somebody tell me whats wrong? been driving me nuts.
------------
change attrib CenterX = Self.Position.x
change attrib CenterY = Self.Position.y
-----------
When Touch = Pressed
Constrain attrib Self.Position.X = min(( self.CenterX +30), max( game.Touches.Touch 1.X ,( self.CenterX -30))))
Constrain attrib Self.Position.Y = min(( self.CenterY +30), max( game.Touches.Touch 1.Y ,( self.CenterY -30))))
but when i hit play the actor doesnt follow the touch, which i thought it should. wheres the error? i've checked the coding repeatedly and cant see it.
------------
change attrib CenterX = Self.Position.x
change attrib CenterY = Self.Position.y
-----------
When Touch = Pressed
Constrain attrib Self.Position.X = min(( self.CenterX +30), max( game.Touches.Touch 1.X ,( self.CenterX -30))))
Constrain attrib Self.Position.Y = min(( self.CenterY +30), max( game.Touches.Touch 1.Y ,( self.CenterY -30))))
but when i hit play the actor doesnt follow the touch, which i thought it should. wheres the error? i've checked the coding repeatedly and cant see it.
Comments
0
...but why are you using CenterX/Y?
It's like you want to keep it in a 30 radius circle, but I'm not thinking that's the right way to do it. Is the actor supposed to stay in a circle, or not move more than 30 pixels at one time?
Also, when not using multi-touch, I use mouse position data.
yeah its suppose to stay within a certain distance from a specific point
and i'm glad you're replying Photics since i've been referencing your textbook
You shouldn't use the mouse data then... unless there are no other buttons.
How is the actor moving. Where does it go when you touch it?
Yours...
min(( self.CenterX +30), max( game.Touches.Touch 1.X ,( self.CenterX -30))))
Textbook...
min((self.X-Center+30),max(game.Mouse.Position.X,(self.X-Center-30)))
You have an extra parenthesis at the end.
atm i'm not using it for anything i'm just learning the technique for future games. but it works now which is cool.
___________________________________________________________________________________
Project Help from Tenrdrmer Click Here
GS BubbleBall Template HERE!!
Stacks Level Selection Template HERE!!
Expanding Option Menu Template HERE!!
Tenrdrmer's Menu # 3 HERE!!
AppSolute Entertainment on Facebook
AppSolute Entertainment on iTunes