Skip to content

Instantly share code, notes, and snippets.

@bulkan
Last active December 17, 2015 06:09
Show Gist options
  • Save bulkan/5563107 to your computer and use it in GitHub Desktop.
Save bulkan/5563107 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
window.CocoonJS_ENV = true;
window.onload = function()
{
// Create a canvas and draw something in it.
var canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 1136;
document.body.appendChild(canvas);
mtest.start(canvas);
};
</script>
<script type="text/javascript" src="o.js"></script>
</head>
</html>
//set main namespace
goog.provide('mtest');
goog.require('lime');
goog.require('lime.Button');
goog.require('lime.Circle');
goog.require('lime.CoverNode');
goog.require('lime.Director');
goog.require('lime.Label');
goog.require('lime.Layer');
goog.require('lime.Scene');
goog.require('lime.Sprite');
goog.require('lime.animation.Loop');
goog.require('lime.animation.MoveBy');
goog.require('lime.animation.RotateBy');
goog.require('lime.animation.ScaleBy');
goog.require('lime.animation.Sequence');
goog.require('lime.animation.Spawn');
goog.require('lime.animation.ColorTo');
mtest.WIDTH = 600;
mtest.HEIGHT = 400;
mtest.start = function(parent) {
//director
mtest.director = new lime.Director(parent || document.body, mtest.WIDTH, mtest.HEIGHT);
mtest.director.makeMobileWebAppCapable();
var menuscene = new lime.Scene;
menuscene.setRenderer(lime.Renderer.CANVAS);
var layer = (new lime.Layer).setPosition(100, 100);
menuscene.appendChild(layer);
var sprite = new lime.Sprite().setFill(100,0,0).setSize(50, 50).setRenderer(lime.Renderer.CANVAS);
layer.appendChild(sprite);
var anim = new lime.animation.Sequence(new lime.animation.Spawn(
new lime.animation.MoveBy(200, 0).setDuration(1.5),
new lime.animation.ScaleBy(2),
new lime.animation.ColorTo(0,200,0)
), new lime.animation.Spawn(
new lime.animation.MoveBy(-200, 0).setDuration(1.5),
new lime.animation.ScaleBy(.5),
new lime.animation.ColorTo(200,0,0)
));
sprite.runAction(new lime.animation.Loop(anim).setLimit(5));
// set active scene
mtest.director.replaceScene(menuscene);
};
goog.exportSymbol('mtest.start', mtest.start);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment