Touch command questions

0 favourites
  • 6 posts
From the Asset Store
In this game you will command the character by voice command.
  • 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?

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • Thanks Ram. You've been a huge help. Would you like to join my beta test, releasing it in 2 days.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)