Generating shadows for tile-based rpg game(or any other game which use 2d graphic)

61 views
Skip to first unread message

dullman

unread,
Nov 16, 2015, 8:50:17 PM11/16/15
to HaxeFlixel
Hello i want to add to my 2d rpg game dynamic shadows, in scene i would use 2 source of light (sun/moon - basically directional light, and fire/lamp/etc. point light), the minimum i want to achieve is to cast a shadows by all objects on map and additional by animated characters, whilst object are standard FlxSprite, animated characters are Sprite Object(Exactly MovieClips). From my thoughts on this object i can create and additional layer named shadow and cast all shadows on this layer, of course it's needs to rewrite render engine which i done half assed to show characters between backgrounds and foregrounds. In this case i'm thinking about rendering each horizontal line in tilemap on different layer with additional  7 rendering index for each tile(Of course it has also layers for characters), for example when we render a third line we would render third line of tilemap with 0 render index, second line of tilemap with 1 render index, first line of tilemap with 2 render index, character, shadow layer from either objects on fourth layer and render index 0 or farther layer with higher render index. What i think that is better to leave FlxTilemap and use openFl Sprite for objects since to be truthful i want to sort display order for objects and characters by their y value.
So what i need is how to create shadows?? My idea is just to draw black bitmap which is transformed object bitmap, but is there any operations which allows to do that or i need to draw it pixel by pixel, also as for character first i need create a bitmap copy of MovieClip so my question is there is a simple way to do that for openfl level (some method/library or framework).


Reply all
Reply to author
Forward
0 new messages