Created
March 28, 2014 22:41
-
-
Save agmcleod/9844509 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
game.PlayScreen = me.ScreenObject.extend({ | |
/** | |
* action to perform on state change | |
*/ | |
onResetEvent: function() { | |
var renderable = me.Renderable.extend({ | |
init: function() { | |
this.parent(new me.Vector2d(0, 0), me.game.viewport.width, me.game.viewport.height / 2); | |
this.filled = false; | |
var _this = this; | |
me.input.registerPointerEvent('pointermove', me.game.viewport, function() { | |
console.log(me.input.mouse.pos); | |
if(_this.containsPointV(me.input.mouse.pos)) { | |
_this.filled = true; | |
} | |
else { | |
_this.filled = false; | |
} | |
}); | |
}, | |
draw: function(context) { | |
if(this.filled) { | |
context.fillStyle = '#ff0000'; | |
context.fillRect(this.pos.x, this.pos.y, this.width, this.height); | |
} | |
}, | |
update: function() { | |
return true; | |
} | |
}); | |
me.game.world.addChild(new me.ColorLayer('', '#000'), 1); | |
me.game.world.addChild(new renderable(), 2); | |
}, | |
/** | |
* action to perform when leaving this screen (state change) | |
*/ | |
onDestroyEvent: function() { | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment