Solved Flash the screen white for a split second.

Question that is answered or resolved.

PS_VITA

Active member
Hi guys,

I've made a square sprite the size of the screen view and I'm trying to have this object appear for a few seconds and disappear as if there was a bomb blast or lightning strike when it rains.

Could someone point me in the right direction, I'm trying to some how map this flash sprite to the view ports rather than the player.

Any ideas would be truly appreciated.
 
Last edited:
Just make a big white sprite, covering like the double size of the screen and its done :)

Extra tip: make it to fade out using drawmethod alpha ;)
Been there done that,
The stages I'm working with are like a metroid game ( 6000 x4000 ) and I'm able to teleport from one end of the room to a completely different area. Your solution and my old solution won't work because sometimes the flash sprite edges can be seen. It's jarring looking.

Hence, I'm hoping I can code the large white square Sprite to the view port of the screen somehow and not the player.


thanks for the suggestions.
 
Last edited:
As O ilu said make the sprite double size of the screen but when spawning the sprite/entity make sure you spawn it at the dead centre of the screens position, make sure the sprites offset is in the centre of the sprite. centre spawning, centre offset, total visible screen coverage.

9gvreL0.png
 
As O ilu said make the sprite double size of the screen but when spawning the sprite/entity make sure you spawn it at the dead centre of the screens position, make sure the sprites offset is in the centre of the sprite. centre spawning, centre offset, total visible screen coverage.

9gvreL0.png
This. you have to use the center of the image as the axis point.
Plus, the @cmd projectile has an option to use the edge of the screen (and not the entity) as the starting point, take a look at the manual.
 
Is this the effect you want to have @PS_VITA :


When Red Balloon was shot, white screen flash is displayed briefly.



Hmmm... does the white screen flash appear before the teleport or after the teleport?
This is exactly what I'm looking for.
Is the little shooter guy actually moving up?

And to answer your telport question,
The flash is just random, but if I telport or I run with the character the flash large sprites can sometimes show the edges.
 
As O ilu said make the sprite double size of the screen but when spawning the sprite/entity make sure you spawn it at the dead centre of the screens position, make sure the sprites offset is in the centre of the sprite. centre spawning, centre offset, total visible screen coverage.

9gvreL0.png
Thank you Danno!
 
> set the flash sprite's offset at it's center.
> set the flash type as "panel"
> spawn it at the center of the current screen (you might be able to find it's coordinates with some clever scripting)


EDIT: Another idea that came into my mind; bind the white flash into your character, so it will be on their location, even if they teleport.
 
Last edited:
> set the flash sprite's offset at it's center.
> set the flash type as "panel"
> spawn it at the center of the current screen (you might be able to find it's coordinates with some clever scripting)


EDIT: Another idea that came into my mind; bind the white flash into your character, so it will be on their location, even if they teleport.
The reason why I don't want to bind the flash to the player is because when say P1 dies the flash will snap to P2 , thus making for a very jarring effect.

I still need to try several solutions mentioned above btw so I'm not ruling anything out yet.
 
You want the flash to snap between players? Or are you saying that binded entities snap between players? Because I work with a lot of binded entities in a 3 players project and never saw this.
 
Is the little shooter guy actually moving up?

No, it's illusion using autoscrolling background which moves downward infinitely 🪄.

Since you want the white screen to move together with the screen, I suggest using type panel with speed 10 for the screen.
Here's the white screen:
Code:
name        Putih
type        panel
speed        10
lifespan      1
subject_to_wall 0
subject_to_gravity 0
subject_to_obstacle 0
subject_to_platform 0
setlayer    1500


anim    idle
    delay    50
    offset    350 250
    frame    data/chars/misc/white.png
    frame    data/chars/misc/empty.gif

I spawned it using this function:
C:
void spawn05(void vName, float fX, float fY, float fZ)
{
    //Spawns entity based on left screen edge and on specified z coord
    //
    //vName: Model name of entity to be spawned in.
    //fX: X distance relative to left edge
    //fY: Y height from ground
      //fZ: Z coordinate

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int Direction = getentityproperty(self, "direction");
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int Screen = openborvariant("hResolution"); // Get screen width

    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

   if (Direction == 0){ //Is entity facing left?                  
      fX = Screen-fX; //Reverse X direction to match facing and screen length
   }

    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX + XPos, fZ, fY); //Set spawn location.
    return vSpawn; //Return spawn}

Spawn it with this:
@cmd spawn05 "Putih" 320 0 250

320 is center of the screen while 250 is the same as Putih's z offset (350 250).
 
Hey guys, I mean no offense, but you are all WAY over complicating this. If what you want is an onscreen flash, all you need to do is draw a screen size box directly. It just so happens OpenBOR has a drawbox function. If it were me, I'd put it in the global update script and then create a simple function that added an int value to a variable. My global script would draw the flash while this variable had a value, then decrement it by 1, and delete the variable at 0.

When an entity wanted to turn the flash on for say, 500 centiseconds, you'd just add this to a frame:

C:
@cmd flash_on 500
frame data/chars/dude/idle_0.png

Drawing a box is relative to the display screen, not the gameworld, so there's no need to mess with all the scrolling and such. Just turn it on, done. Not only is this simpler, it also saves a tiny bit of resources since you don't need an extra model hanging around all the time. Here's the native drawbox function:

C:
drawbox(int position_x, int position_y, int width, int height, int layer, int color, int alpha_mode);

Here's an example of it in action. I use drawbox to create the lightning by briefly drawing a screen size box with alpha blending and randomized colors.


HTH,
DC
 
Not only is this simpler, it also saves a tiny bit of resources since you don't need an extra model hanging around all the time
I really don't know if it save resources - to me, it looks to be the oposite case.
I do prefer to have one simply entity - which I can unload whenever I don't need and I can even reuse an already existing entity for that - rather to have a global updatescript (iow, which will be checked every time and then) and a new variable

But your method is nice.
 
Trust me @O Ilusionista, in this case the script wins. Now in fairness the difference is imperceptible on a human level. You'd need a high end profiler to see it. I only mentioned it at all because of the assumption that "oh, but script will use more resources".

The explanation I gave is more complicated than the implementation. We're talking literally ten lines of code total, if that.

Generally speaking simpler one shot effects and logic are more efficient with pure script. As the complexity increases, spawning an entity starts to win. There's not a hard and fast rule. It just depends on the specific task.

As for your method of the ultimate do it all model, that's a different discussion. I tried that several years ago and a couple of years later decided I hated it. The memory saved isn't worth the organizational and maintenance hassle to me. I minimize need for spawning stuff much as possible, but prefer to stick with dedicated models.

DC
 
I want to thank all of you.
I have enough information to make this work. I changed the status to solved for this topic because I'm getting really good results already with @Bloodbane suggestions and previous ideas and I also want to try what @DCurrent also suggested.

Thanks again!
 
Just make a big white sprite, covering like the double size of the screen and its done :)

Extra tip: make it to fade out using drawmethod alpha ;)
I know this topic is an year old. I am trying to do the same as PS_Vita. I am having a little problem: my flash entity doesn't show up properly and does not look good.
I currently have:

Code:
name        FlashBackGround
type        none
subtype        noskip
nomove        1 1
antigravity    100
setlayer    1050
#alpha        1


anim  idle
    facing        1
    loop        0
    hitfx        data/sounds/beat3.wav
    fastattack    1
    bbox    0 0 0 0
    offset    480 270
    delay 5
    frame    data/chars/players/Skills/BlackBackGround.gif
    frame    data/chars/players/Skills/BlueBackGround.gif
    frame    data/chars/players/Skills/WhiteBackGround.gif
    delay 5
    frame    data/chars/players/Skills/WhiteBackGround.gif
    delay 5
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

Spawn it with this:
Code:
@cmd    projectile 1 "FlashBackGround" 0 0 0

How do you make it fade out using "drawmethod alpha"?
Sorry I am still learning... thank you

Edit:
just found out I was using the wrong type... none instead of panel.
 
Last edited:
How do you make it fade out using "drawmethod alpha"?
Sorry I am still learning... thank you
You don't need to apologize :)

You can use drawmethod shortcut for that. This is my "Vision" select animation from Avengers game (without the scripts to make it easier to read):


anim select
offset 245 270
loop 0
delay 8
sound data/sounds/voices/vision.wav
frame data/chars/vision/shoot00.gif
delay 8
frame data/chars/vision/select00.gif
frame data/chars/vision/att100.gif
delay 12
frame data/chars/vision/select01.gif
drawmethod alpha 6
drawmethod channel 0.90

delay 6
frame data/chars/vision/select01.gif
drawmethod channel 0.80
frame data/chars/vision/select01.gif
drawmethod channel 0.70
frame data/chars/vision/select01.gif
drawmethod channel 0.60
frame data/chars/vision/select01.gif
drawmethod channel 0.50
frame data/chars/vision/select01.gif
drawmethod channel 0.40
frame data/chars/vision/select01.gif
drawmethod channel 0.30
frame data/chars/vision/select01.gif
drawmethod channel 0.20
frame data/chars/vision/select01.gif
drawmethod channel 0.10
frame data/chars/vision/select01.gif
delay 60
frame data/chars/misc/empty.gif

You have to start with "drawmethod alpha 6" and with the first setting of the channel transparency, like " drawmethod channel 0.90"

This number means the alpha percentage, so 0.90 means 90% transparency.
 
Back
Top Bottom