How to loop a movement?
hamzawesome
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
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 ?
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.
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...
You cannot have a random value for an 'Every' timer, not only does it not work, but it doesn't actually make sense !
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.
@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. ME DERP!
It's a common misconception, it comes up a lot: "Hey my random timer doesn't work!"
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)
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?
It will stick to its original number. Okay thanks @Socks !
@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.
If you simply want an actor to repeatedly move across the screen at a set interval then do this: (example attached)
That helped me figure it out, thank you very much!!