Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / How to implement multiple touch inputs do two separate tasks

Author
Message
NeedHalp
8
Years of Service
User Offline
Joined: 20th May 2016
Location:
Posted: 8th Jun 2016 21:41
I want to make my sprite move left and right if I hold left and right side of the screen. At the same time, if I press the center of the screen, the sprite will shoot a missile. However, I am completely lost on how to make the sprite move left or right while shooting all at the same time.
I tried incorporating GetRawTouch functions but I'm too inexperienced to know how to implement something like this.
Here is my code for now:

NeedHalp!
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Jun 2016 10:22
This is a basic structure for reading and acting on touch events. The value is used to indicate that the initial touch has already been processed, but the touch is still continuing.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
NeedHalp
8
Years of Service
User Offline
Joined: 20th May 2016
Location:
Posted: 9th Jun 2016 22:26
I tried implementing the structure you suggested me at it works! ... Kinda. I seem to have two problems. Although the rocket shoots while moving (touching the middle screen while holding onto either left or right side of the screen), rocket stops moving and shooting at the same while rocket is decelerating (only touching the middle screen while my rocket still moves slowly to deaccelerate). My rocket sprite gradually slows down when the screen is not pressed and when I tap on the middle button while it slows down, the rocket abrutly stops to shoot and continues to deaccelerate while I want it to continually to deaccelerate while shooting. Another problem I'm having is that when I press the left side and the right side of the screen at the same time, the rocket actually speeds up. Is there a way to check two touches in the touch event first, then do something instead of looking at it one by one? Thank you!

My trimmed down code:

Login to post a reply

Server time is: 2024-11-22 03:57:10
Your offset time is: 2024-11-22 03:57:10