douglas Posted September 14, 2016 Share Posted September 14, 2016 I don't understand why i can't use the game instance instead of Phaser.Math.PI2 in this scratch code https://jsfiddle.net/johndo101/cfx0zxo3/ Here you can find a pointer i use to understand javascript : prototype -> http://www.w3schools.com/js/js_object_prototypes.asp data object method -> http://www.w3schools.com/js/js_object_methods.asp Quote Link to comment Share on other sites More sharing options...
mattstyles Posted September 14, 2016 Share Posted September 14, 2016 `game` is an instance of Phaser.Game, not an instance of Phaser, although its unlikely that a constructor would copy over dynamic members from Phaser even if it was. Hence Math is not defined and you're trying to access a member of an undefined variable and therefore explosion. Re-read those links you posted, particularly in reference to adding members to a prototype. From your point of view it pretty much works the same as any other C-like language. douglas 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.