Photics — Cool Tip #8 — Particles (Relative to Scene)

PhoticsPhotics Member Posts: 4,172
edited November -1 in Working with GS (Mac)
BOT is nearing completion. I'm optimizing the game as the project is finishing up. One of the things I'm fixing is the screen flash. Instead of spawning a 1024 particle, I'm reducing it to 512.

I'm in a good mood, so I'm feeling generous. Here's a cool formula from the game...

max((256-self.Position.X),min((768-self.Position.X ),(0-self.Position.X+game.TANK-X)))

max((256-self.Position.Y),min((768-self.Position.Y ),(0-self.Position.Y+game.TANK-Y)))

What I'm doing with the above expressions is creating a screen flash.

Sometimes you want things to explode based on a scene position, rather than a position relative to an actor. Particles are great for explosions, but there isn't a drop-down menu to select "Scene" for the "Emitter Offset". So, instead of waiting for GameSalad to add the option for you, it can be done with math.

Basically, I'm subtracting the position of the actor, that zeros things out, allowing me to position particles relative to the scene.

If you like information like this, you might also enjoy The Unofficial GameSalad Textbook.

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Photics said:

    max((256-self.Position.X),min((768-self.Position.X ),(0-self.Position.X+game.TANK-X)))

    max((256-self.Position.Y),min((768-self.Position.Y ),(0-self.Position.Y+game.TANK-Y)))

    So you're putting these in the x and y offset section of a particle behavior? This causes a white image to cover the screen for an instant no matter where the actor emitting the particle is in the scene? Is that right?

    Thanks!
  • PhoticsPhotics Member Posts: 4,172
    scitunes said:
    So you're putting these in the x and y offset section of a particle behavior?

    It's in the X & Y "Emitter Offset" fields... in the Velocity / Position tab.
    scitunes said:
    This causes a white image to cover the screen for an instant no matter where the actor emitting the particle is in the scene? Is that right?

    The length of the duration is not determined by these expressions. But yeah... the idea is to create a flash of color on the screen... that covers the whole screen area... regardless of where the main actor is located in the scene... which is activated by another actor's particle behavior. You seem to understand what's going on.

    Previously I was using a 1024 particle, which is much larger than necessary, as the screen size is 320x480 / 480x320... so I use 512 to cover both orientations.

    The Min / Max is to compensate for when the actor is off-center from the middle of the camera box.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    So you put this in the bomb actor and even if you hit the bomb while in the corner of the camera box the flash will cover the entire screen?

    cool tip
Sign In or Register to comment.