HTML and CSS Reference
In-Depth Information
director.makeMobileWebAppCapable();
goog.events.listen(scene,['mousedown','touchstart'],function(e){
var circle = new lime.Circle()
.setSize(50,50)
.setFill(Math.floor(Math.random()*255),
Math.floor(Math.random()*255),
Math.floor(Math.random()*255));
scene.appendChild(circle);
circle.setPosition(e.position.x,e.position.y)
.setOpacity(0.5);
e.swallow(['mousemove','touchmove'],function(e) {
circle.runAction(
new lime.animation.MoveTo(e.position)
.setEasing(lime.animation.Easing.LINEAR)
);
});
e.swallow(['mouseup','touchend'],function(e){
circle.runAction(new lime.animation.Spawn(
new lime.animation.FadeTo(1),
new lime.animation.ScaleTo(1.5)
));
});
});
director.replaceScene(scene);
};
This example is a modified version of the helloworld example you can generate from the command line with
bin/lime.py create helloworld . Getting the example up and running is more involved than using
Crafty because you need to download LimeJS, run the bin/lime.py init command to download the de-
pendencies, and then create the project directory.
As you can see, everything is a little more verbose because of the heavy namespacing that the Google Closure
library uses, but because of the power of the library, the code still manages to stay fairly compact.
A couple of nice things that LimeJS does are worth mentioning. The first is the mechanism it uses to track
touches. The e.swallow code intelligently applies only to the same touch that initiated the original event. It
can track the touch identifier for you internally, so you don't need to worry about it.
The animation system that LimeJS provides makes it easy to set up fire-and-forget animations (much
like
jQuery).
It
also
enables
you to
combine
those
animations
to
run concurrently
via
lime.animations.Spawn .
LimeJS is licensed under the Apache License, which enables you to use it for any purpose personal or com-
mercial, as long as proper attribution is provided. To learn more about LimeJS and download the engine, visit
www.limejs.com .
Search WWH ::




Custom Search