Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / 2D Shadows (for Blendman)

Author
Message
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 24th Jan 2018 21:20 Edited at: 24th Jan 2018 21:39
So, following on from the requests thread I mentioned its easily possible to do 2D shadows in AppGameKit and I was asked for some example code.

I rushed this together tonight... so it may have a few bugs but it should be obvious how it works to anyone who tries it out or takes a look at it.



There are 3 functions:
Create2DQuickShadow(ID,180)
This creates a sheer shadow at 45 degrees to the right with an alpha of 180

Create2DSheerShadow(ID,30,1.2,200)
This creates a shadow with an angle of 30 degrees off vertical to the right with a shadow length of 1.2 x the original height with an alpha of 200

Create2DRotationShadow(ID,30,150)
This creates a shadow rotated by 30 degrees with an alpha of 150


please note:
1) This only works on images that have alpha values (obviously) So thats png's with transparent pixels in them.
2) A one pixel border of completely transparent pixels is needed at left and right side of the image or you will get shadow smear due to texture wrapping effects
3) I set the depth of the shadow sprite to just just '1' deeper than the original sprite... you will have to set this to whatever you need t to be (typically just slightly less than the background/ground sprite
4) All these functions assume the base of your image is the feet of the character...if there is space between his feet and the bottomof the image then he will appear to float unless you move his shadow appropriately.


Gives results similar to



Ohh...and im aware that it probably should be 'SHEAR' not 'SHEER' but ...ummm...whatever
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 25th Jan 2018 00:24
great Bengismo ! well done
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 26th Jan 2018 16:58
I don't do 2D, but damn that looks awesome bengismo!
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 31st Jan 2018 11:52
Hi
Thanks a lot. I will try it soon
AGK2 tier1 - http://www.dracaena-studio.com

Login to post a reply

Server time is: 2024-03-29 07:14:42
Your offset time is: 2024-03-29 07:14:42