How to create a lightning effect?

butterbeanbutterbean Member Posts: 4,315
Toby might be good at this since your game looked professional and amazing!

How can you create the illusion of lightning in the background?

For example, I want the entire level to light up and flicker for a few seconds or the backdrop....

Comments

  • SDMGSDMG Member Posts: 280
    if i have an imagefile and want to light a part of the image ... i open Photoshop, create a white circle on an extra layer... blur it and change the layer-option to overlay... you could try to give it a yellow tone too...
  • quantumsheepquantumsheep Member Posts: 8,188
    I did this in one of my recent projects.

    I literally made an actor that's 512x512 to cover the whole screen. Colour is white with an alpha of .5

    Rule is simply a timer that says 'after .2 seconds, destroy this actor'

    Now all you need is a spawner that will spawn this actor whenever you want and you get a momentary flash on the screen.

    Added to the rain in my game, it actually works well in my context - might now work well for your game, but only you can decide that ;)

    Hope that helps,

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • SDMGSDMG Member Posts: 280
    AAAAH hahaha!!! "Lightning!!" I completly missunderstood this ;) ... OK forget what i wrote ;))
  • quantumsheepquantumsheep Member Posts: 8,188
    The way you love me is frightening... etc ;)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • butterbeanbutterbean Member Posts: 4,315
    I was wondering what your response was SDMG, but now I realize it was "lighting" that you thought I was referring to :)

    Thanks Quantum! That sounds like a great idea! I'll try that.

    If you want it to flash, say 3 times for about a couple of seconds each, how would you set up a rule to do that?

    I wanted to have the lightning in the background for one level flash every couple of seconds or so, so I guess I could just set up a timer rule for that...
  • sewinstonsewinston Member Posts: 51
    There is an old school animation trick for this. Do an animation sequence where the first frame is the background image with the lightning bolt draw in. For the second frame make the whole frame white. For the third frame invert the color of the background (open apple + i in photoshop). If you play it back at 24-30 frames per second it will give you a pretty cool lightning strike.
  • quantumsheepquantumsheep Member Posts: 8,188
    That sounds awesome Sewinston - May try that ;)

    The obvious way to have multiple flashes, Butterbean, is to just add timers to the spawner.

    Have a timer that says spawn flash after 1 second
    Then another timer that says spawn flash after 2 seconds
    and a third etc etc

    Hope that helps!

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • butterbeanbutterbean Member Posts: 4,315
    Sewinston, that does sound cool!

    I may go with Quantum's idea for now for ease of use, but if it doesn't work for my game, I will try it :)

    I finally have about 2 games that are looking pretty good, hopefully when I've fixed some other elements, I'll be able to show one of them :)
  • butterbeanbutterbean Member Posts: 4,315
    Quantum

    How did you set up your rule again? I created an actor for the lightning and sized it to the dimensions of my scene, did you place the actor over the scene. or are you spawning it?

    If so, how did you create the coordinates? Just wanted to see how you did yours, in the meantime I'm gonna try a few things :)
  • quantumsheepquantumsheep Member Posts: 8,188
    I spawn it, co-ordinates are X240, Y160

    Might help to have it a little bigger than the scene, just to make sure you get it all.

    I've been using it all to good effect ;)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • TobyToby Member Posts: 478
    Lightning, that's an interesting concept. Relatively easy to create but the trick is in the animation and creating different lightning each time it flashes. No two bolts are the same or in the same position. I'd probably cheat and just create a series of 3 frame cycle animations in flash. No need to make the image as big as the screen, just the maximum size of the bolt. Create a series of BOLT actors with a simple 3 frame animation. (fork, flash, fade) make the first frame transparent so nothing is seen on the stage, or just change the alpha. Then create another actor which sits off stage that will contain the controls for the lighting actors. Inside the actor create a random X placement behaviour for your actors in a timer which controls visibility and x placement. Something like that. I imagine there's a more elegant way using code, but it works.
  • butterbeanbutterbean Member Posts: 4,315
    Quantum:

    I used the same coordinates too, but yes I agree, making the actor bigger than the scene to ensure coverage is great :)

    Did you use various different timers in the spawner or one timer?
Sign In or Register to comment.