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 / How to create a shadow on a sprite?

Author
Message
Mungkeh_Man
12
Years of Service
User Offline
Joined: 11th Apr 2012
Location:
Posted: 24th Jun 2014 20:09
Firstly, my apologies if there is a function for this, I have looked but can't find anything.

In short, I'm developing a platform game, but the platform sprites look odd on top of the background sprite. Just like one image dropped onto another one (which of course, they are!).

I thought a shadow on the platform would help tie the two together but can't see how to do this.

Has anyone got any ideas?
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Jun 2014 01:14
One method I've used is to make a copy of the sprite, and put it onto the next zdepth, so if the current sprite is at 1000 depth, set this cloned sprite to 1001, and maybe offset it's position on X and Y a little as well.
Then, the cool bit - you colour it jet black, and alpha fade it, like SETSPRITECOLOR(spr,0,0,0,128)

This makes a silhouette of your sprite, great for shadows. You could even just make a function to add a shadow sprite, like use a sprite number and clone a new sprite from it, offset the depth and position and change the colour. That might be the easiest way for platform shadows, just remember to disable physics on them.

I am the one who knocks...
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 25th Jun 2014 09:16 Edited at: 25th Jun 2014 09:18
if u use physics or have more sprites its maybe better to make the
shadow in a paint program. also drawing 1 sprite is faster than two.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
Mungkeh_Man
12
Years of Service
User Offline
Joined: 11th Apr 2012
Location:
Posted: 25th Jun 2014 20:34
Thank you both, I'll have a play around and see what works best in my game.

It's a shame there isn't a built in sprite function...even MS Word does shadows!
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 26th Jun 2014 09:00 Edited at: 26th Jun 2014 09:03
V2 will support fullscreen shaders which, in theory if implemented fully, can be used to create dynamic shadows based on sprites and light sources. Some info and examples of this can be found here.

Here's also an awesome open-source example of real-time shadows integrated in box2d for a different engine but the principle would be the same:

DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 26th Jun 2014 10:04
I'm hoping that the shaders will come with some good explanations and examples. I'm not familiar with writing shaders but love the idea of being able to use them.

Login to post a reply

Server time is: 2024-11-25 06:24:12
Your offset time is: 2024-11-25 06:24:12