Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Created January 21, 2012 01:51
Show Gist options
  • Select an option

  • Save hughfdjackson/1650729 to your computer and use it in GitHub Desktop.

Select an option

Save hughfdjackson/1650729 to your computer and use it in GitHub Desktop.
var purr = require('../utils/purr')
var scene = purr.create('scene')
scene.init = function(images){
var canvas = scene.director.canvas
// --- Scene Data --- //
var data = {
background : {
backgroundImage: images.background
, location: [0, 0]
}
, play_button : {
backgroundImage: images.play_button
, location: [(canvas.width - images.play_button.width)/2, 200]
}
, title : {
backgroundImage: images.title
, location: [(canvas.width - images.title.width)/2, 75]
}
}
// --- Scene Behavior --- //
var background = purr.create('actor', data.background)
, play_button = purr.create('actor', data.play_button)
, title = purr.create('actor', data.title)
play_button.mouseClick = function(){
scene.director.switchToNextScene(1000, true, true)
}
var container = purr.create('actorContainer', { isGlobalAlpha: true, bounds: [0, 0, canvas.width, canvas.height] })
purr.anim(container, 'alpha', { values: [0, 1], frameTime: [0, 1000]})
purr.add(container, [background, play_button, title])
purr.add(scene, container)
}
module.exports = scene
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment