Photics — Cool Tip #8 — Particles (Relative to Scene)
Photics
Member Posts: 4,172
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.
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
Thanks!
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.
cool tip