vmars316 Posted March 26, 2016 Share Posted March 26, 2016 Hello & Thanks , I am making my way thru game tutorial - http://www.w3schools.com/games/tryit.asp?filename=trygame_controllers_keys and I would like to know , what is the purpose of a 'name :' label ( canvas : , start : , clear : ) ? var myGameArea = { canvas : document.createElement("canvas"), start : function() { this.canvas.width = 480; this.canvas.height = 270; this.context = this.canvas.getContext("2d"); document.body.insertBefore(this.canvas, document.body.childNodes[0]); this.interval = setInterval(updateGameArea, 20); window.addEventListener('keydown', function (e) { myGameArea.key = e.keyCode; }) window.addEventListener('keyup', function (e) { myGameArea.key = false; }) }, clear : function(){ this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); } Also , for ' ("canvas"), ' , why the comma ' , ' ? Thanks Link to comment Share on other sites More sharing options...
davej Posted March 26, 2016 Share Posted March 26, 2016 See... http://www.w3schools.com/js/js_objects.asp Link to comment Share on other sites More sharing options...
vmars316 Posted March 27, 2016 Author Share Posted March 27, 2016 See... http://www.w3schools.com/js/js_objects.asp Ok , I see , those are just properties , just a more complex version of below: var person = { firstName: "John", lastName : "Doe", id : 5566 }; While I've got ya on the phone , let me ask : window.addEventListener('keydown', function (e) { myGameArea.key = e.keyCode; } is ' e ' a reserved word ? Also myGamePiece = new component(30, 30, "red", 10, 120); is 'component' a reserved word ? Pls , where can I find a list of all js reserved word ? Thanks again.. Link to comment Share on other sites More sharing options...
davej Posted March 27, 2016 Share Posted March 27, 2016 e is an event object which is passed by the function parameter list. component is an object class which is apparently defined in the game. It isn't a reserved word in Javascript. Reserved words... http://www.w3schools.com/js/js_reserved.asp Link to comment Share on other sites More sharing options...
vmars316 Posted March 27, 2016 Author Share Posted March 27, 2016 Thanks davej ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now