Here is my code a small part of my code....
function joysticks()
if CurrentTouch.state == BEGAN or CurrentTouch.state == MOVING then
if CurrentTouch.x < 300 then
d = color(234, 229, 229, 255)
fill(b)
strokeWidth(10)
ellipse(CurrentTouch.x, CurrentTouch.y, 100, 100)
else
d = color(234, 229, 229, 255)
fill(b)
strokeWidth(1)
ellipse(CurrentTouch.x, CurrentTouch.y, 100, 100)
end
else
ellipse(150,150,100,100)
ellipse(600,150,100,100)
end
end
In the game I'm making I am going to make a character be controlled by a type of common joystick controller. The main part I'm having trouble with is the joysticks. There are two joysticks, one on the left and one on the right. I am having a problem naming the "ellipse" methods something different than the syntax of it, thus I can't figure out how control only ONE when there are two on the screen. I've tried turning them into variables but failed..
CurrentTouch only tracks a single touch. For twin-stick controls, you'll need to keep track of multiple touches by writing a function called touched and storing positions indexed by touch ID in a table. Look at the documentation for the touch type and the multitouch example project for more info.
If you want more example code, or just want to get your controls implemented quickly, check out my Controllers project which contains classes for implementing video game controls: http://github.com/npryce/codea-controllers Look at the VirtualStick and SplitScreen classes.
Thank you very much, this is exactly what I needed :) I should not need much more help anymore, your examples hit the spot and even future questions I was going to ask like how you split the screen in half. I've bookmarked your profile, it will be great to study with.
It looks like you're new here. If you want to get involved, click one of these buttons!