Hi, so as an alternative control system for people who can’t operate their iPhones and iPads using tilt ive been looking into an onscreen joystick that just moves left and right with buttons for shoot and loop the loop for Starsceptre.
I’ve got a good example for the joystick but when I click on a button it overrides the joystick turning it off.
I’m using touch and not current touch. I’m wondering how I retain two touches. Is it by using touch.id one set for joystick and one each for the two buttons? I’m also trying to fix the joystick in one place and I’ve almost got that working.
This is the joystick code that creates the stick and locks it to horizontal controls
if controltype=="c" and game== go and touch.y < scY*50 and touch.y > scY*0 and touch.x < scX*35 and touch.x > scX*10 and touch.state == BEGAN then
control.centre = vec2(touch.x,scY*25)
control.touch = vec2(scX*25,scY*25)
control.active = true
elseif controltype=="c" and game== go and touch.y < scY*50 and touch.y > scY*0 and touch.x < scX*50 and touch.x > scX*0 and touch.state == MOVING then
control.touch = vec2(touch.x,scY*25)
if control.touch:dist(control.centre) > control.radius - control.innerRadius then
control.touch = control.centre + (control.touch - control.centre):normalize()*(control.radius - control.innerRadius)
end
else
control.active = false
end
And here is the button for shooting. Do both sets need different Touch ID for you each?
if game==go and sh.state ~= sh.deady and sh.state~=sh.jumpin and sh.state~=sh.pullup and sh.state~=sh.dive and paralysis <1 and levelend==false
--and CurrentTouch.y < scY*35+yy
and (((controltype=="b" or controltype=="c") and touch.y < scY*29 and touch.y > scY*15
and touch.x < scX*78 and touch.x > scX*65) or (controltype=="a"
and touch.y < scY*75+yy))
and pauser==false
then
if touch.state==BEGAN and auto==true then
autofire=true
if safetybullet==0 then
fire=true
end
end
if touch.state==ENDED then
if auto==true then
autofire=false
if (level==3 and timer<5100) then
else
safetybullet=0
end
else
if level==3 then
if leveltimer<5100 then
if safetybullet==0 then
fire=true
end
else
if safetybullet==0 then
fire = true
end
end
else
if safetybullet==0 then
fire = true
end
end
end
end
else autofire=false
end
Thanks
Rich