Touch command questions

Get help using Construct 2

Post » Sun Sep 27, 2015 2:55 am

I have gotten my game to perform appropriately while testing in a web browser. So now trying to translate that to androind, and replacing my mouse functions with touch functions.

My mouse functions were as follows.

Condition - Every Tick; Action - Set object angle towards mouse.x, mouse.y
This was to make my object always face the mouse

Condition - Left click is down & System every 0.25 seconds; Action - Spawn bullet
This was to shoot a bullet every 0.25 seconds

I tried translating them to mobile, with either the on touch, on hold, or intouch functions. Only result i have gotten is my main object (a ship) spinning infinitely, and will point to where I click to shoot, to then continue spinning.

My desired result, is to be able to hold my finger anywhere on the screen, the ship to follow my finger, and shoot at the interval of 0.25 seconds. Additionally, when someone is not holding on the screen, the ship's orientation is the last place a finger was on the screen.

Can anyone help me out a bit?
B
9
S
1
Posts: 49
Reputation: 551

Post » Sun Sep 27, 2015 3:11 am

After messing with this I have a better understanding of WHY it's doing this, just don't have the knowledge of how to stop it. I'm guessing with the game not detecting an input, it's searching for it therefor the ship just spins?

I got my firing function down correct with the "isintouch" condition. Now I just need to find a way to make it so that when the screen is not being touched, the ship stays stationary towards the position last touched.
B
9
S
1
Posts: 49
Reputation: 551

Post » Sun Sep 27, 2015 7:21 am

use a couple of variables (personal choice would be for instance variables on the ship but global variables will work) lets call these "LookAtX" and "LookAtY". Change these two variables when you touch the screen and use these variables to set the player angle as required. this way the ship will know which way to face even if there is no touch
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Sun Sep 27, 2015 10:49 pm

Thanks Ram. You've been a huge help. Would you like to join my beta test, releasing it in 2 days.
B
9
S
1
Posts: 49
Reputation: 551

Post » Mon Sep 28, 2015 4:03 am

Ram, little extra help off of what you just told me there.

I decided to use an onscreen joystick instead, because my finger blocked the view of my target. Got the joystick working as needed with the code below.

Event: spStick dragdrop is dragging
Action: spStick set ivAngle to angle(sppad.x, sppad.y, self.x, self.y)
Action: spShip set angle to spStick.ivAngle degrees

Event: Touch is in Touch
Event: Every .25 seconds
Action: Spaceship spawn Bullet

Event: spStick dragdrop drop
Action: spStick set position to spPad

That controls every behavior I want, except the constant spinning of the ship then a finger is not on the screen. I tried a couple variations of what you suggested above, but could not get it to work. How do I get the ship now to stop at the angle I want.
B
9
S
1
Posts: 49
Reputation: 551

Post » Mon Sep 28, 2015 12:08 pm

first impression is I can't see anything wrong with that - are you altering the spShip angle anywhere else ? I will try to have a play later.

Happy to look at your beta if you want.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 22 guests