Hi.
I have 3 button in my game and wrote a code for them. but somrtimes arrow buttons don't work. this is my multi touch code, anyone can tell me where is the problem?
if keyboard <> 1
event[1] = GetRawFirstTouchEvent(1)
event[2] = GetRawNextTouchEvent()
event[3] = GetRawNextTouchEvent()
touch[1] = GetSpriteHit(ScreenToWorldX(GetRawTouchCurrentX(event[1])),ScreenToWorldX(GetRawTouchCurrentY(event[1])))
touch[2] = GetSpriteHit(ScreenToWorldX(GetRawTouchCurrentX(event[2])),ScreenToWorldX(GetRawTouchCurrentY(event[2])))
touch[3] = GetSpriteHit(ScreenToWorldX(GetRawTouchCurrentX(event[3])),ScreenToWorldX(GetRawTouchCurrentY(event[3])))
//Move to Right
if TouchVal = 0
if (touch[1] = ControlBtnsSpr[1] or touch[2] = ControlBtnsSpr[1] or touch[3] = ControlBtnsSpr[1])
if GetSpriteExists(ControlBtnsSpr[1]) = 1
if state = 0 then state = 1
TouchVal = 1
endif
endif
endif
if TouchVal = 1
if (touch[1] = ControlBtnsSpr[1] or touch[2] = ControlBtnsSpr[1] or touch[3] = ControlBtnsSpr[1])
if GetSpriteX(Player) < 80
SetSpritePosition(Player,GetSpriteX(Player) + (speed#*deltaTime#)*0.7,GetSpriteY(Player))
SetSpritePosition(EngineSprite,GetSpriteXByOffset(Player)-3.2,GetSpriteYByOffset(Player)+4)
endif
else
if state = 2
state = 0
SetSpriteImage(Player,PlayerImage[1])
SetSpriteAnimation(Player,128,128,16)
PlaySprite(Player,10,1,1,15)
TouchVal = 0
endif
endif
endif
//Move to Left
if TouchVal = 0
if (touch[1] = ControlBtnsSpr[2] or touch[2] = ControlBtnsSpr[2] or touch[3] = ControlBtnsSpr[2])
if GetSpriteExists(ControlBtnsSpr[2]) = 1
if state = 0 then state = 3
TouchVal = 2
endif
endif
endif
if TouchVal = 2
if (touch[1] = ControlBtnsSpr[2] or touch[2] = ControlBtnsSpr[2] or touch[3] = ControlBtnsSpr[2])
if GetSpriteX(Player) > -5
SetSpritePosition(Player,GetSpriteX(Player)-(speed#*deltaTime#)*0.7,GetSpriteY(Player))
SetSpritePosition(EngineSprite,GetSpriteXByOffset(Player)-3.2,GetSpriteYByOffset(Player)+4)
endif
else
if state = 4
state = 0
SetSpriteImage(Player,PlayerImage[1])
SetSpriteAnimation(Player,128,128,16)
PlaySprite(Player,10,1,1,15)
TouchVal = 0
endif
endif
endif
//Create Player Bullet
if GetSpriteExists(ControlBtnsSpr[3]) = 1
if (touch[1] = ControlBtnsSpr[3] or touch[2] = ControlBtnsSpr[3] or touch[3] = ControlBtnsSpr[3])
if GetRawTouchReleased(touch[3]) = 1
if fire = 0
CreatePlayerBullet()
if GetSoundExists(PlayFireSound) = 1
PlaySound(PlayFireSound)
endif
fire = 1
endif
endif
endif
endif
for f = 1 to MaxBullet
if GetSpriteExists(PlayerBullet[f]) = 1
SetSpritePosition(PlayerBullet[f],GetSpriteX(PlayerBullet[f]),GetSpriteY(PlayerBullet[f])-2)
if GetSpriteY(PlayerBullet[f]) < -5
DeleteSprite(PlayerBullet[f])
if fire = 1 then fire = 0
endif
endif
next f
endif //Check Keyboard not Exist
Thanks.