How to cast shadows that change with time

2

Index

Attached Files

The following files have been attached to this tutorial:

.capx

shadow-cast-2.capx

Download now 209.83 KB

Stats

5,899 visits, 10,666 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 21 Dec, 2013. Last updated 19 Feb, 2019

What if the sprite can jump?

If your sprite can jump or fly then you have to do a little bit more maths to make the shadows convincing - height above ground, sun azimuth and sun elevation all have to be carefully considered. Luckily some close approximations will produce effects good enough for most 2D or 2.5D games.

The 8-direction movement has no jump behavior so I made a very simple one using custom movement. Each tick the robot’s height above ground is calculated with reference to a dynamic ‘jump_startY’ variable that is factored for the changes in position caused by 8-direction movement as the robot jumps. Without this, moving and jumping up the screen would cause the apparent jump height of the robot to increase and moving quickly down the screen would put the robot below its starting jump Y value - all of which would cause the shadow to be positioned incorrectly.

Conclusion

That’s it! Have a look in the capx, it contains more comments to help you understand my thought processes. I hope that you found that these ideas useful and if you have any feedback then please let me know how to make this tutorial better and I'll get on it! All I have to do now is think of a game where I can put all of this to work! Now, what about multiple light sources...

.CAPX

shadow-cast-2.capx

Download now 209.83 KB
  • 0 Comments

Want to leave a comment? Login or Register an account!