Hold down touch/mouse button and track finger drag on screen

ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296
edited August 2014 in Working with GS (Mac)

Hi all

I'm working on a tank game where I want the turret that is an actor constrained to the tank to fire when the player holds on the screen and drags to destroy a target.

I have it so a mouse button selects a waypoint and when the button is released it moves the tank to its new X & Y position.

I want the firing mechanism to be activated by selecting a point and drag the players finger on screen, the turret would then automatically follow this movement and I can then get the tank shell firing every odd second.

Q: How to I get the hold down, touch and track the dragging finger position for the turret to follow?

Been bugging me all day and not getting far and been searching GS Forums but nothing close.

Thanks in advance guys.

It takes a Zombie to know a Zombie!!!

Comments

  • colandercolander Member Posts: 1,610

    Use a Constrain Attribute action, self.Rotation To vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    Hi Colander,

    It takes a Zombie to know a Zombie!!!

  • colandercolander Member Posts: 1,610
    edited August 2014

    I don't know without looking at your game. Put it in there and play with it until it works how you want. I did notice in my test project it wouldn't work in a rule with "When touch is pressed" but "When mouse button is down" did work.

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @colander said:
    I don't know without looking at your game. Put it in there and play with it until it works how you want. I did notice in my test project it wouldn't work in a rule with "When touch is pressed" but "When mouse button is down" did work.

    ok, cool will give it a try...thanks again :)

    It takes a Zombie to know a Zombie!!!

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    How do you register a hold mouse button down like when you hold your finger down on the screen?

    It takes a Zombie to know a Zombie!!!

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296
    edited August 2014

    i want it so that if the player holds down their finger it locks in the tank position x and y but if the player just tap on the screen the TANKFIRE attribute is true and it fires a shell.

    I can't seem to get the hold down part nailed down as when you press and hold down on the screen (mouse button down) to lock in the waypoint, GS thinks your tapping the screen and it fires.

    How can I separate the movement and the fire rules? been driving me crazy!!!

    It takes a Zombie to know a Zombie!!!

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @colander said:
    Use "When touch is released" to fire it.

    that doesn't work...

    I have a rule that locks the waypoint - this is when the player touches the invisible actor that covers the screen...this then locks the x and y and the tank moves to that wayoint....i've got that working.

    Now, when I touch the invisible actor that covers the screen, the tank fires?

    i've added a rule saying

    i've touch is released, then change attribute 'TANKFIRE' to true. When you tap on the invisible actor to select a new waypoint, the tank fires anyway?

    Any glues?

    It takes a Zombie to know a Zombie!!!

  • colandercolander Member Posts: 1,610

    Not without working on the project, maybe a fire button on your HUD.

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @colander said:
    Not without working on the project, maybe a fire button on your HUD.

    Yeah I think that would be easier but really wanted to have multi touch control without clunky on screen joysticks and such.

    Oh well, might have to rethink this one.

    It takes a Zombie to know a Zombie!!!

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    Does anyone know a good template for using touch gestures with Gamesalad?

    It takes a Zombie to know a Zombie!!!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Does the attached demo help?

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @RThurman said:
    Does the attached demo help?

    Hi RThurman

    Yeah, thats nearly there...will use this to get started on the movement.

    Thanks for your help on this one...been driving me loopy for a few days now.

    Think this will really help! :)

    It takes a Zombie to know a Zombie!!!

Sign In or Register to comment.