Limit Flick To Just Once
robert.mccarthy
Member Posts: 165
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,
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
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.
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?
Just need to fix these two issues then I am almost ready for publish!
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