Recurring behaviour without using Timer

zzap64zzap64 Member Posts: 405
edited February 2012 in Working with GS (Mac)
Hello
I'm trying to repeat various actions in loops without using the timer.
example, move an actor on a scene between two points in a recurring loop and also mirror'ing an actor image in a loop so it switches every second.
Any help much appreciated.

Comments

  • SAZ_1SAZ_1 Member Posts: 397
    moving between two points is done by telling that object if self pos X (or Y, if going up down) is less than 800 change attribute self motionX to 300 ... then if self posX is bigger than 2000 change attribute self motion x to -300 ( obviously subsitute the values with whatever you need in relation to the scene position and so on , but that works really well.)
  • pitsopitso Member Posts: 53
    lol i didn't understand half of what you guys said hahahah
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    You can use the modulo function in conjunction with the game.timer

    So in effect you saying every x seconds, do something.

  • zzap64zzap64 Member Posts: 405
    ah ha, the change self x,y did everything I needed it to do. thanks for the advice :)
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    Also don't forget to get out your beige keyboard and use:
    POKE 53272,21 make my game great
    POKE 53272,23 make apple feature my game
    POKE 53280,C borrow some of that Rovio unexplainable sticky magic

    Works every time
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @zzap64

    "example, move an actor [in] a scene between two points in a recurring loop"

    Constrain X position to:
    AAA*cos( self.Time *BBB)+CCC

    AAA = the size of the movement from the centre point - so sticking 500 here will move your object 250 pixels left of the centre point and then 250 pixels right of the centre point and then 250 pixels left and then 250 pixels right of the centre point . . . . forever or up until you die, whichever comes first.

    BBB = the speed of the movement.

    CCC = the centre point of the movement.

    In this example (100*cos( self.Time *100)+400) the actor will move left and right in a loop, 50 pixels each way . . . so it will move from 350 to 450 back and forth forever (see caveats above about your own demise).
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    "also mirror'ing an actor image in a loop so it switches every second"

    1) Get your actor . . . inside GS make a copy . . . flip the second actor horizontally.

    2) Place both actors in the scene on top of each other.

    3) On the top actor place a timer: Every 1 second change attribute alpha to 1-alpha.

  • zzap64zzap64 Member Posts: 405
    thanks Tynan, very useful.
  • zzap64zzap64 Member Posts: 405
    for the flip, i just changed the flip horizontal attribute when it reached the x,y.
Sign In or Register to comment.