Probleme with start/stop via interpolate-function, look at my script
akimann
Member Posts: 62
Problem: I have two actor: One Start/Stop Button an a moving actor.
I want to move the actor from left to right when the Button is clicked. When I click the button again, the actor should move back to the start position and stay there. When I click the button once more, it should start moving again from left to right. But with my script it doesn´t work.
When I click start first, everything works fine. When I click the Start/Stop-button again the actor moves back to the start position but after this he is jumping back to that position from where he moves back and keep on moving from left to right *why???* :-(
For the Clickbutton I do have the script:
When touch is pressed
Change Attribute <game.xxxx> to (game.xxxx+1)%2
that results to change the value xxxx in "1" or "0" after each click
Here´s the script from the moving actor:
When Attribute <game.xxxx= 1
interpolate attribute <self.Position.X) to 320
Duration 5 Function <linear>
Otherwise
interpolate attribute <self.Position.X) to 0
Duration 1 Function <linear>
That´s all
But where is my ugly bug???
I want to move the actor from left to right when the Button is clicked. When I click the button again, the actor should move back to the start position and stay there. When I click the button once more, it should start moving again from left to right. But with my script it doesn´t work.
When I click start first, everything works fine. When I click the Start/Stop-button again the actor moves back to the start position but after this he is jumping back to that position from where he moves back and keep on moving from left to right *why???* :-(
For the Clickbutton I do have the script:
When touch is pressed
Change Attribute <game.xxxx> to (game.xxxx+1)%2
that results to change the value xxxx in "1" or "0" after each click
Here´s the script from the moving actor:
When Attribute <game.xxxx= 1
interpolate attribute <self.Position.X) to 320
Duration 5 Function <linear>
Otherwise
interpolate attribute <self.Position.X) to 0
Duration 1 Function <linear>
That´s all
But where is my ugly bug???
Comments
instead of
"interpolate attribute <self.Position.X) to 0"
I used
"constrain attribute <self.Position.X) to 0"
didn´t guess why this works perfect, but it works an I´m going to have a bear now :-)