On Thu, Aug 22, 2013 at 4:26 PM, Art Aquino <[email protected]> wrote:
> Im trying to work on a simple lighting engine for my tile game. The idea > is to set the tile opacity so the unlit tiles are black or very dark, and a > segment (or ray) is being projected from my player where the first point is > at my player and the second point follows my mouse pointer so I can "aim" > my light source. I want to be able to get the tiles that this segment > intersects, and then change their opacity. > > The problem is that I dont see a method in cocos to accomplish this. It > looks like the only way is to use a Rect to get cell regions. Any ideas? > ## Sugestion 1 In a past pyweek we used some illumination at the openGL level, and your flashlight needs (light a cone-like zone in one direction) is similar to the light effect when the shotgun is fired. You can checkout that project at http://code.google.com/p/aiamsori/source/checkout Walk with WASD but choose the facing direction with mouse; fire with space. Shotgun at the next right room from the spawn point. Note: In windows I needed to use the old version 5 avbin.dll (put in system32) , the last ones crashed the game after a while. The good is that you don't need to do raytracing, It does a two-pass draw on the GameLayer, one for world and one for lights (which are simple sprites) The custon draw you can see at http://code.google.com/p/aiamsori/source/browse/trunk/gamelib/main.py#477 ##Sugestion 2 At the detail level of tiles and raytracing, think a ray as a physical bullet, fire in the direction of ray , use RectMapCollider to see where the bullet impacts. Obviusly you don't want to make visible the bullet, and want to run in an own time (fast and with coarse steps); also you want to end the trace at some predetermined distance. ##Sugestion 3 Adapt a general intersection of ray with walls. We used one for bullet hit in the same game mentioned before, you can look at http://code.google.com/p/aiamsori/source/browse/trunk/gamelib/wall_colision2.py -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cocos-discuss. For more options, visit https://groups.google.com/groups/opt_out.
