*** Turning off Flashing sprite

This forum is currently in read-only mode.
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • Hi guys.

    I've just run into this problem with flashing sprites.

    I have certain sprites that are constantly flashing slowly (set up by a single flash command), but sometimes I need to hide the sprites, sometimes show them without flashing, and sometimes flashing again.

    For some reason, after you have made a sprite flash, you cannot hide it afterwards, whether the flash is still going or not.

    Also, you cannot stop it flashing and show it normally once you've started it.

    I imagined that using the "visible" command would override the flashing and show the sprite, but no.

    I can fix this part of the bug by using the flash command with 0.001 values for both parameters, but that's not the point.

    I can set up my own flashing timer easily enough, so I don't have to rely on the flash command, but I thought I'd flag this bug up for others to try.

    Given the rarity of new builds these days, I'm going to have to create my own timing on flashing so that it doesn't hold up this project for weeks (or months) waiting for the bug to be squashed.

    Would appreciate it if others could confirm that it's a bug so that it may be squashed in future builds.

    Cheers,

    Krush.

  • Well flash works off of visible/ invisible afaik, so setting visibility wont work, and not really a bug per say. Instead I would use the sin behavior set to opacity with a low period. That way you can do what ever you like to it, invisible, or just disable the behavior with a function, and opacity compare.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a test cap: http://db.tt/QXvbs0 req 0.99.84 or newer.

    As long as the object is flashing, trying to make the object visible or invisible has no effect. It looks like this is by design because all flash does is make the object visible and invisible at regular intervals.

    I'm having no problem making the object visible or invisible once the flash is done.

    Stopping the flash is fairly simple by using the flash action with just zeros:

    -> Sprite: Flash for 0 seconds with 0 seconds interval[/code:1rjaxayk]
    but since you said "that's not the point" I guess that won't help.
    
    I find the way flash currently works to be acceptable, but that's just me.  It's simple enough to do those actions you need done.  For example to hide a flashing object it would only take two actions:
    [code:1rjaxayk]-> Sprite: Flash for 0 seconds with 0 seconds interval
    -> Sprite: Make Invisible
    [/code:1rjaxayk]
  • Make a new event called On flash finished and add action Make Invisible. That will fix it.

    <img src="http://i46.tinypic.com/3160nzd.png">

  • Hi guys.

    As I said earlier, I was using 0.001 for both parameters to end the flash and then hide or show it, but it wasn't working 100%.

    I'm pretty sure, if my memory serves correct, that MMF2 would override the flash command when using show or hide, and I guess I expected the same logic to apply with Construct.

    It looks like the problem I was having, which was flagged up by your posts, was that by using a value greater than zero for the parameters meant that the following command to show or hide it didn't work because the flash hadn't actually finished it's duration.

    Using zero meant that it effectively switched it off and the following command would work as expected.

    I've spent some time today writing custom flash routines, and all works well, but it's sod's law that I find out flash would work with zero parameters AFTER I'd rewritten it.

    Never mind.

    Some parts of my game require the flashing to be in sync with other objects, and with my custom flashing, all sprites stay in sync regardless of when they are switched on or off.

    But it's good to know that I can use flash for other parts of the game that don't need to be synced.

    I still think that using show or hide should override the flash properties, instead of ignoring it if the flash duration hasn't expired.

    It's no biggy if we have to use 2 commands instead of 1, but it just seems logical.

    Thanks again guys.

    Krush.

  • You could create your own flash by setting up a group that makes it invisible at intervals, then to stop it just simply disable the group. Of course you would probably need a group for each sprite, unless you want them all to act the same way.

  • The way I did it was to use a group to keep it all tidy (but it will always be enabled).

    Then I used a variable "Flasher" to determine which global state the flash was in.

    Set at 1 originally, every 0.25 seconds it will be multiplied by -1, meaning that it will toggle between 1 and -1.

    Then I used private variables to determine whether a sprite was in a flashing state (-1), a stable state (1), or an invisible state (0).

    So it all looked like this:

    GROUP [ FLASHING]

    Every 0.25

    --Flasher=Flasher*-1

    Flasher=1:

    --Sprite1.state=0

    Hide Sprite1

    --Sprite1.state=1

    Show Sprite1

    --Sprite1.state=-1

    Show Sprite1

    Flasher=-1:

    --Sprite1.state=0

    Hide Sprite1

    --Sprite1.state=1

    Show Sprite1

    --Sprite1.state=-1

    Hide Sprite1

    All of the conditions are indented under the every 0.25 seconds condition, so they are not constantly showing and hiding, which would be too processor heavy.

    As you can see, setting both state actions for a sprite to hide means that you never see it, setting them both to show means that it's just visible, and setting one to show and the other to hide will cause it to flash.

    Perfect for keeping everything in sync.

    Krush.

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