Limit Flick To Just Once

robert.mccarthyrobert.mccarthy Member Posts: 165
edited November -1 in Working with GS (Mac)
Hi All,

I have started to implement a 'flick' on my game. Basically, I have a ball, which I want to flick and then as soon as it is moving i cannot flick again until it stops. I have the following:

Rule: When 'mouse.button' is down ->

constrain 'self.rotation' to 'vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )'
change 'self.touchX' to 'self.Position.X' ////self.touchX is an attribute on the actor itself
change 'self.touchY' to 'self.Position.Y' ////self.touchX is an attribute on the actor itself
constrain 'self.Motion.Linear Velocity.X' to '10*( game.Mouse.Position.X - self.Position.X )'
constrain 'self.Motion.Linear Velocity.Y' to '10*( game.Mouse.Position.Y - self.Position.Y )'

So I need help with the following:

* Only allow a flick to occur when the ball has stopped working?
- I have tried not allowing the flick when the ball is moving greater than 0 but this causes issues

* I do not want the ball to jump to where I put my finger on screen. At the moment, if the ball is in position 50,50 but I put my finger on position 100,100, it will jump to my finger. I just want it to work like a flick game.

Any and All help appreciated.

Thanks,

Comments

  • DrGlickertDrGlickert Member Posts: 1,135
    As far as the flick to stop working, I'd do a game.attribute boolean;

    RULE: When attribute self.motion.linear velocity.x = 0 AND self.motion.linear velocity.Y = 0 then set BallMoving to false

    On the ball; on the flick rule, set it to change attribute to TRUE.

    That way the player cannot flick the ball when the ball is already moving.

    Let me think about the 2nd issue for a bit. That one is new to me.
  • robert.mccarthyrobert.mccarthy Member Posts: 165
    Hello DrGlickert,

    Thanks for the solution for the first problem.

    I have tried this however, and having this implementation stops you being able to 'flick' the ball because as soon as it starts to move it recognises this and then changes the boolean to stop the flick happening.

    This means that you can only nudge it a little before it kicks in.

    Anything else I should add to allow it to actually flick and then not allow any more until it has completely stopped?
  • DrGlickertDrGlickert Member Posts: 1,135
    Have you tried on MOUSE UP, not on MOUSE DOWN? I do that with my shooter game, that way the player can touch (theoretically aim) and then when they lift up the shot is fired.
  • robert.mccarthyrobert.mccarthy Member Posts: 165
    Yes tried MOUSE UP, this just means that the ball moves to where the mouse is.

    Just need to fix these two issues then I am almost ready for publish!
  • ValanValan Member, BASIC Posts: 410
    For the ball not to jump you need a rule that calculates the offset when the actor is pressed.

    At the moment you're changing the actors position to the touch position.

    Create a new self attribute called offset and calculate a position for the actor to move to that essentially moves it to its existing place. I think the offset would be self.offsetx = game.mouse.position.x - self.position.x

    Then change self.position.x to game.mouse.position.x - self.offsetx

    so hopefully it stays in the same place.

    Basically you are calculating the difference between the old position and the new position and then deleting that little bit from the new position so that all stays the same.

    Hope this helps
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    as far as only flick when not moving try the rule the Dr. Game you but make it like less than 5 or 10 instead of equal to 0 that way the ball is basically stopped but a small movement doesn't mess up your game.
Sign In or Register to comment.