Hello Guest

Author Topic: Sprites casting shadows  (Read 8306 times)

minicades

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Sprites casting shadows
« on: April 03, 2012, 02:10:32 am »

Can anyone recommend a sprite shadow solution.  I was thinking I could make a matching animation sprite shadow on the ground - but then I would have to double everything - double the atlases, maps, animation and double the input of events and triggers.  Then theres the issue of the shadow being cast onto the ground or onto walls which requires a shift of rotation - (but then what about half on the wall and half on the ground).


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites casting shadows
« Reply #1 on: April 03, 2012, 07:38:44 am »
This is really specific to the type of game you're doing. Let me know what you're after and I will try to offer some suggestions.

minicades

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Sprites casting shadows
« Reply #2 on: April 04, 2012, 01:28:13 pm »
Hi unikron - its the same game I sent you a link to in a PM - skateboarding 2D sideways scroller (with perspective) - kinda like double dragon.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites casting shadows
« Reply #3 on: April 08, 2012, 07:25:01 pm »
The best way to do this is probably to use a flipped sprite, tinted black with 30% alpha or somethign like that. When its tinted black, it will lose all the color content, and as a result will look more or less like a shadow.

To get perspective, you will need to modify the code to offset the top of the sprite along the local Y axis (simulating a skew matrix). To get the shadow going up a wall, simply use the clipped sprite sample - split the shadow up into two parts, and skew them with different amounts to simulate varying levels of perspective.

The easiest way to go about this is to take the clipped sprite sample and modify it to add the skew component.