Restarting A Movement

jmorrisonscjmorrisonsc Member, PRO Posts: 2

I am trying to create a movement from point A to B then after it is touched or a certain time has passed the actor moves back to position A. I am able to get it to move from A to B then both actions work , if i touch the actor it moves back to A or if I allow the time to pass it moves back to A. The issue is I am unable to get the action to restart or loop back to the start and run again. If anyone has any insight here that would greatly be appreciated. I have been stuck at this point for going on 3 days now and have exhausted all that I can do. Thanks.

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2016

    Could you give the coordinates for the A and B positions.

  • jmorrisonscjmorrisonsc Member, PRO Posts: 2
    edited April 2016

    Let preface this by saying this is my first game and I really don't know what I am doing, lol. I am on windows, I select my scene, I choose layers and expand my layers, then I select the actor, in the attributes panel the position is X: 247 and Y : 18 with the word "real" off to the right. I placed the actor on the screen and then used the "move to" behavior to get the action I am looking for set with a random timer. I am looking to have 12 instances of this actor all moving up and down randomly, whether they are touched or not, only touching will give a score and a nice spawn actor graphic. I hope this is enough info thanks. EDIT: I needed to include this - the first "move to" that makes the actor appear to come from under the board into view is 247,240("point B") the second "move to" sends the actor back under and out of view 247,60.("point A"). Once its touched or the time has passed I need the actor to go back down which it does but then I need it to start over and do the same actions again. All of this is done inside the "instance" not the "prototype"

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2016

    @jmorrisonsc said:
    247,240 / 247,60.

    You can do this sort of thing numerous ways depending on what kind of effect you want.

    You could try this: Make a self.attribute, let's call it 'A'.

    When touch is pressed:
    --Change A to 1-A
    --Move to: X = self.position, Y= 150+((( self.A * 2)-1) * 90)
    (relative to scene / run to completion ticked)

    . . . . . . . . . . . . . . .

    If you wanted an automated looping movement you could try:

    Constrain self.positon Y to:
    90 * sin( self.Time * 100)+150

    (the '90' is the range of movement, the '100' is the speed, and the '150' is the centre point of the movement)

Sign In or Register to comment.