Make sprites flash after 1 second ? :( :(

  • After using construct for well over a year now I thought I had most things nailed but obviously not.

    Its possible I am being really dumb but here goes.

    link to example file

    https://drive.google.com/file/d/0B6AQ9znz3zwxSkUwbl9pbDZINkNCRVlzRGJMZW1UQ1FrS1lJ/view?usp=drivesdk

    Anyway. Basically I am trying to get some pickup sprites to flash after a second, the sprites are in a family.

    I have 2 pickups spawned by a spawner sprite every 1 and 1.5 seconds respectively.

    Both the pickups are in a Family called Pickups.

    The pickups family has flash behavior and a "MyTimer" variable (to which I ad dt every frame)

    + System: Every 1.0 seconds

    -> Sprite: Spawn Pickup on layer 0 (image point 0)

    + System: Every 1.5 seconds

    -> Sprite: Spawn Pickup2 on layer 0 (image point 0)

    + System: Every tick

    -> Pickups: Add dt to MyTimer

    Then I am attempting to get them individually flash after 1 second (you know to indicate they are about to disappear)

    + Pickups: MyTimer > 1

    ----+ System: Trigger once

    -----> Pickups: Flash: Flash 0.1 on 0.1 off for 1.0 seconds

    but If I do this above the first pickup spawned flashes after one second but none of the others flash.

    + System: For each Pickups

    + Pickups: MyTimer > 1.5

    ----+ System: Trigger once

    -----> Pickups: Flash: Flash 0.1 on 0.1 off for 10 seconds

    If I do this above (add a for each into the condition)

    The fist pickup spawned flashes after 1 second but the others disappear after one second. (this makes no sense to me)

    + System: For each Pickups

    + Pickups: MyTimer > 1.5

    -> Pickups: Flash: Flash 0.1 on 0.1 off for 10 seconds

    If I do this above (remove the trigger once but keep the for each) none flash but they all individually disappear after 1 second (assuming the flash is being continually triggered)

    + Pickups: MyTimer > 1.5

    -> Pickups: Flash: Flash 0.1 on 0.1 off for 10 seconds

    This results in same as previous.

    So where is my dumb ass going wrong.....?????

  • NetOne

    Not looked at the c3p as I'm not using C3 yet, but from what you've written you're spawning a new Pickup every second at the same location as the old pickup (which is the same time you wait to flash), so it could be hiding the one that is flashing behind it. You might want to extend the wait to spawn to 3 seconds instead of 1.

    Also, rather than count dt in a variable, you could use the Timer behaviour on the Pickup

    Pickup: On created -> Pickup: Start Timer "StartFlash" for 1.0 (once)

    Pickup: On timer "StartFlash" -> Pickup: Flash 0.1 on 0.1 off for 1.0 seconds

    Pickup: On flash ended -> Pickup destroy

    Edit: Here's a C2 capx example - https://www.dropbox.com/s/huyfxdvwxtttu ... .capx?dl=1

    I spawn to the left every second, to the right every 3 seconds, notice that the one to the left doesn't appear to flash (because new one appears in front) even though all the other code is affecting them the same with regards to flash and destroy.

  • OddConfection

    Hey man Thanks,

    I cant look at your dropbox as Im locked down at work (will check it later) but just FYI

    in my example my pickups also have bullet behavior so float away from the spawn so are not over lapping...

    (edit Im sure you can open any C3 projects in the free online version of C3 just maybe cant edit/save if they use features not supported by free version)

    However, ( I havent used timers much in the past. )

    but I tried your suggestion using

    + Pickups: On created

    -> Pickups: Start Timer "Flash" for 1.0 (Once)

    + Pickups: On Timer "Flash"

    -> Pickups: Flash: Flash 0.1 on 0.1 off for 10 seconds

    And this works ! The pickup begin to flash individually when ready.

    So thanks really appreciate your help.

    Ill now have to look into replacing a variable based timers with timer behavior in my game.

    It is still bugging me why the other way doesn't work tho.....

    cheers.

  • Because of "Trigger once while true".

    This condition makes it so that it is trigger only once, for the very first instance.

    Following instances are not triggered.

    To have it in events, consider doing as so :

    Add a boolean family instance variable to the Pickups family ("IsFlashing", false by default)

    + Pickups: [X] Is IsFlashing (inverted => Is not IsFlashing)

    + Pickups: MyTimer > 1.5

    -> Pickups: Flash: Flash 0.1 on 0.1 off for 10 seconds

    -> Pickups: Set IsFlashing to True

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Because of "Trigger once while true".

    This condition makes it so that it is trigger only once, for the very first instance.

    Following instances are not triggered.

    To have it in events, consider doing as so :

    Add a boolean family instance variable to the Pickups family ("IsFlashing", false by default)

    + Pickups: [X] Is IsFlashing (inverted => Is not IsFlashing)

    + Pickups: MyTimer > 1.5

    -> Pickups: Flash: Flash 0.1 on 0.1 off for 10 seconds

    -> Pickups: Set IsFlashing to True

    Ok thanks man.

    My logic was.

    + Pickups: MyTimer > 1 (Will pick every Pickup who's timer is greater than 1)

    ----+ System: Trigger once

    -----> Pickups: Flash: Flash 0.1 on 0.1 off for 1.0 seconds (Will turn on flash only once for each picked Pickup)

    But you are saying that actually

    this will only pick the first Pickup whose timer > 1

    then turn its flashing on

    and then as the trigger once applies to the first condition as long as there are pickups on screen with timer > 1 it wont ever run again.

    Yes it does make sense now and this is exactly what I am seeing.

    I will have to look into this properly as It possibly means a lot of my Construct thinking may be flawed which could explain a few bugs im having difficulty squashing.

    Hm........ Brain Ache.....

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)