Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Phaser game.add.physicsGroup() Question: This is a function expression, correct? What are .add and .physicsGroup()?

Game is supposed to be the game object, so .add and .physicsGroup() seem to be methods that belong to this object. Correct me if I'm wrong please. :-)

1 Answer

Steven Parker
Steven Parker
243,201 Points

Without more context this is a bit of a guess, but this looks like a method invocation, not a function expression. A function expression would include the word "function" or the "=>" symbol.

As for "add", it appears to be a property of the "game" object, And "physicsGroup" looks like a method of the "add" property.

To facilitate the most accurate answers, always provide a link to the course page you are working with.

Hello. Thank you for your response. Here is a link to the course: https://teamtreehouse.com/library/introducing-javascript The teacher is using a game library called Phaser.js

I found some good information at the MDN too, which explains the method/object terminology in Phaser. This is supposed to be an introductory course and I finished it, but it's becoming extremely useful because it allows the student to go deeper into structure of a javascript program. :-)

Here's the link for the MDN tutorial on Phaser for 2d games: https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_breakout_game_Phaser

I think this is the best source for looking up all things Phaser related: go here http://phaser.io/sandbox/edit/EfACfDDf

and click on the HELP tab on the right. :-)