How to loop a movement?

hamzawesomehamzawesome Member, PRO Posts: 30

I want this movement to repeat itself, and not just happen once. The movement involves the actor flying into the screen from off-screen, but I want it to happen over and over again forever, until the player loses. Here is the movement:

move in direction: 180 relative to: scene in a(n): additive way
at a speed of: 300

How do I make this movement repeat itself after a certain interval of time, over and over again? Let's say I wanted it to repeat itself once every 10 seconds, how do I do that? I tried using timer and loop blocks but neither of them worked.

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    What happens to this actor once it has has flown into the scene ? Does it remain in the scene ? Continue moving until is goes off the opposite side of the screen from the one it came in from ? Bounce back so it leaves the screen on the same side it came in from ? Explode ? Disappear ? . . . . etc etc ?

  • hamzawesomehamzawesome Member, PRO Posts: 30

    It enters the screen from the right side of the screen and moves straight until it disappears on the other side of the screen. Basically it flies off screen and thus disappears.

  • SLOCM3ZSLOCM3Z Member Posts: 797

    Make a spawner, make a timer in said spawner, put it off-screen to the right, in said timer: every (random(1,3)) :do: spawn actor killer, in direction:180, then there are two boxes in the spawn rule, in the second(this is the Y the actor will spawn on), put random(100,300). Make Wall actor, put it to the far left. Then in killer actor: if collision is with Wall :do: destroy. Hope this helps...

  • SocksSocks London, UK.Member Posts: 12,822

    @jdlcrater said:
    timer: every (random(1,3))

    You cannot have a random value for an 'Every' timer, not only does it not work, but it doesn't actually make sense ! :smile:

    Using random in an Every timer will see it select a random value and use this random value 'Every' time. That is to say the value will not change.

  • SLOCM3ZSLOCM3Z Member Posts: 797

    @Socks said:
    You cannot have a random value for an 'Every' timer, not only does it not work, but it doesn't actually make sense ! :smile:
    Using random in an Every timer will see it select a random value and use this random value 'Every' time. That is to say the value will not change.

    I'm sorry. I thought it worked.

  • SLOCM3ZSLOCM3Z Member Posts: 797

    @Socks... I have earned this lol. The only reason I think that would work is because I thought every time it does the rule it would update and check again for a random number. So this is what I thought it would do: RULE: every random(1,5), pick 3, do rule, look for another random number, do rule etc. etc. But even that doesn't make sense. :s ME DERP!

  • SocksSocks London, UK.Member Posts: 12,822
    edited October 2015

    :smile:

    @jdlcrater said:
    The only reason I think that would work is because I thought every time it does the rule it would update and check again for a random number.

    It's a common misconception, it comes up a lot: "Hey my random timer doesn't work!" :smile:

    @jdlcrater said:
    So this is what I thought it would do: RULE: every random(1,5), pick 3, do rule, look for another random number, do rule etc. etc. But even that doesn't make sense.

    Yeah, if it picks 3 then it will do the rule Every 3 seconds.

    There are lots of ways to do a random timer, @tatiang has a few, I use this one:

    Game.attribute = XXX

    Rule for the spawner:
    --After XXX seconds
    ----Spawn the thing you want to spawn
    ----Change XXX to random (1,5)
    ----Destroy (destroy this actor)
    ----Spawn the spawner (respawn this actor)

  • SLOCM3ZSLOCM3Z Member Posts: 797
    edited October 2015

    @Socks said:
    Yeah, if it picks 3 then it will do the rule Every 3 seconds.

    There are lots of why to do a random timer, @tatiang has a few, I use this one:

    ame.attribute = XXX

    Rule for the spawner:
    --After XXX seconds
    ----Spawn the thing you want to spawn
    ----Change XXX to random (1,5)
    ----Destroy (destroy this actor)
    ----Spawn the spawner (respawn this actor)

    Thanks Sir. Okay... I see this timer and think could we do...

    --Every game.XXX
    ---spawn thing
    ---change game.XXX to random(1,5)
    Would that work? Or would it stick to its original number?

  • SLOCM3ZSLOCM3Z Member Posts: 797

    It will stick to its original number. Okay thanks @Socks :) !

  • IceboxIcebox Member Posts: 1,485
    edited October 2015

    @hamzawesome
    1- Make a self integer attribute call it mytime.
    1-make a self real attribute , call it my firstposition ,
    2-place a change attribute and change self.firstposition to self.position x ,
    3-put a timer after (self.mytime) seconds run to completion change attribute self.positionx to self.firstposition
    4- move in direction: 180 relative to: scene in a(n): additive way
    at a speed of: 300

    now place your actor on the scene double click it and put the value you want on the mytime attribute , if you want him to go back after 10 seconds or after 5 seconds or etc.

    if you want your actor to move from left side to the right side without giving it time , just constantly moving , ignore all the rules and go the scene attributes tick wrap x

    Hope this is what your looking for and good luck

  • hamzawesomehamzawesome Member, PRO Posts: 30
    edited October 2015

    @Icebox1910 said:
    hamzawesome
    1- Make a self integer attribute call it mytime.
    1-make a self real attribute , call it my firstposition ,
    2-place a change attribute and change self.firstposition to self.position x ,
    3-put a timer after (self.mytime) seconds run to completion change attribute self.positionx to self.firstposition
    4- move in direction: 180 relative to: scene in a(n): additive way
    at a speed of: 300

    now place your actor on the scene double click it and put the value you want on the mytime attribute , if you want him to go back after 10 seconds or after 5 seconds or etc.

    if you want your actor to move from left side to the right side without giving it time , just constantly moving , ignore all the rules and go the scene attributes tick wrap x

    Hope this is what your looking for and good luck

    I followed every step you listed, here is an image of the backstage for the actor whose movement I want looped:

    The problem is, now the actor doesn't show up in the scene at all when I play the game. Is there something I did wrong? When I click the actor in the scene, am I supposed to change the myfirstposition attribute under "Actor" in the bottom-left corner? Specifically I'm talking about this area: http://i1213.photobucket.com/albums/cc461/Hamzawesome/Attributes_zpsrf8jdehq.png

    By the way, yes the "Black Thumbnail" is the actor I'm trying to loop.

  • SocksSocks London, UK.Member Posts: 12,822

    @hamzawesome said:

    If you simply want an actor to repeatedly move across the screen at a set interval then do this: (example attached)

  • hamzawesomehamzawesome Member, PRO Posts: 30

    @Socks said:

    That helped me figure it out, thank you very much!!

Sign In or Register to comment.