HTML and CSS Reference
In-Depth Information
var touch = e.originalEvent.changedTouches[0];
if( {;
} else {
var point = stage.browserToWorld(touch.pageX,touch.pageY);
var box = stage.insert(new Q.Sprite({
x: point.x, y: point.y, w: 20, h: 20
box.bind("contact",function(sprite) {
The first block also needs to be updated to type static so that it can act as a platform for the other objects.
Finally, the box elements added when you touch on an empty part of the screen add in a listener to the con-
tact event to turn any object they touch blue. The result is shown in Figure 14-4 .
Figure 14-4: Box2D Physics applied to SVG.
Creating a Cannon Shooter
With physics and SVG in Quintus, you now have all the pieces you need to build a simple physics-based, knock-
things-down game. (Box2D, after all, is the 2-D physics engine that powered Angry Birds .)
The fun part of physics-based gameplay is that as a developer you don't need to do much to get the basic
functionality working: The physics engine handles a lot of it for you. The flip side of this, however, is that the
physics-based games require a lot of parameter tweaking to be fun and work well.
Search WWH ::

Custom Search