Right, this tutorial teaches you how to implement easy 2D lighting using Yoyogame's Game Maker 8 through the use of surfaces. For a reference on what surfaces are, check out ChevyRay's tutorial here:
http://forums.tigsource.com/index.php?topic=7441.0I've made an example .gmk available here:
http://www.host-a.net/u/jtsandoval/lighting%20example.gmkHow This Works:You have 2 objects - a control object (which I have called
oCameraControl) and a light object(
oLight). Upon initialization,
oCameraControl draws a surface over the entire screen. For each instance of
oLight in the room, the object
oCameraControl will cut out holes in that surface in the given X and Y coordinate of each
oLight.
Things to Remember:1. Note that GM's surfaces
may have issues on certain computers. Also note that surfaces don't work in 3D mode.
2. The checkbox for
oLight that is labeled 'visible' must be unchecked (it should not be seen). The code in
oCameraControl does all the drawing.
3. The sprite sLight can be animated for a more 'glowy' effect.
4. That's pretty much it.
Here's a pic of the type of effect this can achieve: