Created
March 26, 2011 13:27
-
-
Save joecritch/888277 to your computer and use it in GitHub Desktop.
Experiments with the new oCanvas library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Author: Joe Critchley | |
oCanvas Experiments | |
*/ | |
var canvas = oCanvas.create({ | |
canvas: '#canvas', | |
background: '#222', | |
fps: 60 | |
}); | |
var circles = [], disabled = false; | |
var hover_circle = canvas.display.ellipse({ | |
x: 100, | |
y: 100, | |
radius_x: 100, | |
radius_y: 100, | |
stroke: '1px #666' | |
}); | |
canvas.addChild(hover_circle); | |
canvas.bind('mousemove', function() { | |
hover_circle.x = canvas.mouse.x; | |
hover_circle.y = canvas.mouse.y; | |
}); | |
hover_circle.bind('click', function() { | |
if(disabled) { | |
return; | |
} | |
disabled = true; | |
var new_circle = this.clone({ | |
fill: '#999' | |
}); | |
canvas.addChild(new_circle); | |
circles.push(new_circle); | |
new_circle.animate({ | |
radius_x: 50, | |
radius_y: 50 | |
}, '600', 'ease-in-out', function() { | |
disabled = false; | |
}); | |
}); | |
canvas.setLoop(function() { | |
// ?? why did I need a set-loop to get the mousemove event working? | |
}); | |
canvas.timeline.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment