Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
121 lines (79 sloc) 2.54 KB
<html>
<head>
<title>Cyclic Vacuum Cannon</title>
<style type="text/css">
body {
padding: 0px;
margin: 0px;
background-color: #333;
}
</style>
</head>
<body onload="new pt.CyclicVacuumCannonApp">
<canvas id="canvas"></canvas>
<script type="text/javascript" src="http://code.createjs.com/easeljs-0.5.0.min.js"></script>
<script type="text/javascript" src="http://code.createjs.com/tweenjs-0.3.0.min.js"></script>
<script type="text/javascript">
var c = createjs,
presstube = {},
pt = presstube,
p;
pt.CyclicVacuumCannonApp = function() {
var canvas = document.getElementById("canvas"),
stage = new c.Stage(canvas),
bgRect = new c.Shape,
centeredContainer = new c.Container;
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
bgRect.graphics.clear().beginFill("555").drawRect(0, 0, canvas.width, canvas.height);
centeredContainer.x = canvas.width / 2;
centeredContainer.y = canvas.height / 2;
}
function spawnNoun() {
var noun = new pt.Noun;
noun.x = Math.random()*200 - Math.random()*200;
noun.y = Math.random()*200 - Math.random()*200;
noun.rotation = Math.random()*30 - Math.random()*30;
centeredContainer.addChild(noun);
}
function onPress() {
spawnNoun();
}
resize();
window.onresize = resize;
c.Ticker.setFPS(30);
c.Ticker.addListener(stage);
stage.addChild(bgRect);
stage.addChild(centeredContainer);
bgRect.onPress = onPress;
}
pt.Noun = function() { this.initialize(); };
p = pt.Noun.prototype = new c.Container;
p.Container_initialize = p.initialize;
pt.Noun.libraryAnimSpriteSheet = new c.SpriteSheet({"animations": {"all": [0, 2]}, "images": ["nounLibraryAnim.png"], "frames": {"regY": 42, "height": 90, "regX": 22, "width": 42, "count": 3}});
p.initialize = function() {
this.Container_initialize();
var noun = this,
libraryAnim = new c.BitmapAnimation(pt.Noun.libraryAnimSpriteSheet);
function materialize() {
c.Tween.get(libraryAnim).to({scaleX: 1, scaleY: 1}, 1000, c.Ease.quintOut);
}
function dematerialize() {
c.Tween.get(libraryAnim).to({scaleX: 0, scaleY: 0}, 1000, c.Ease.quintOut).call(onDematerializeComplete);
}
function onDematerializeComplete() {
noun.parent.removeChild(noun);
}
function onPress() {
dematerialize();
}
libraryAnim.scaleX = libraryAnim.scaleY = 0;
noun.addChild(libraryAnim);
libraryAnim.gotoAndStop(Math.floor(Math.random() * libraryAnim.spriteSheet.getNumFrames()));
materialize();
noun.onPress = onPress;
}
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.