Nephelococcygia Posted January 28, 2018 Share Posted January 28, 2018 I was wondering what is the best way to handle shadow for a "character". I made a character and i want to put a shadow at the bottom a kind of "circle" with opacity, for convenience let's say it's gonna be a transparent PNG. The way i can think of : - (1) Just add the sprite to the game, this leads to duplicated calculations in the update part cause i have to update both the "character" sprite and his shadow; - (2) Add the shadow as a child sprite of the "character", this leads to having the shadow on top of the sprite instead of back to it; - (3) Add the "character" sprite as a child of the shadow sprite, this seems not logical, but it works somehow; - (4) Create a group and add both the shadow and the sprite, (havn't test it but most likely) this leads to define specific property to the group for the size, the position and the overflow boundaries for collision relative to the "character" sprite and the shadow; - (5) Using a filter (Shader) applied on the hole game, with my character position as uniform to render the shadow directly on the "groundLayer". What do you think please ? Is there a better way that i am missing ? Thanks. Link to comment Share on other sites More sharing options...
mickeyren Posted January 29, 2018 Share Posted January 29, 2018 if you are okay with static shadows, maybe this will be good enough for you: https://phaser.io/examples/v2/display/sprite-shadow Link to comment Share on other sites More sharing options...
Tom Atom Posted January 30, 2018 Share Posted January 30, 2018 On 28. 1. 2018 at 8:06 PM, Nephelococcygia said: - (4) Create a group and add both the shadow and the sprite, (havn't test it but most likely) this leads to define specific property to the group for the size, the position and the overflow boundaries for collision relative to the "character" sprite and the shadow; this is the best option in my opinion. Link to comment Share on other sites More sharing options...
Recommended Posts