Here is another demo from DevCon5. Yesterday we showed you an action game, now we will show you something completely different. A Drag And Drop style decoration application of the type we produced by the dozens ta Mattel throughout the first 10 years of this century. We present to you: Christmas Tree Decorator. Music by Mike Peters/The Children Of The Revolution. This was developed for Google chrome and has not been optimized for other browsers yet.
One of the most interesting thing about this demo (to us) is that we display the mouse button pointer when rolling over things that can be clicked and dragged. This might not sound like much, but since the HTML5 Canvas does not contain any DOM objects, we had to achieve the effect with our own custom code. Here is how we did it:
- Next we test to see if the mouse if over any of the bulbs. We keep all bulbs in single array named clickBlocks to make this easy.
- The key lines in that code, change the cursor depending on what the mouse is over using CSS
theCanvas.setAttribute(“style”, “cursor: pointer”);
theCanvas.setAttribute(“style”, “cursor:default” );
Don’t forget, you can join our new HTML5 Game Development forums and talk about this kind of stuff all day long!