Jump to content

Why use "this " keyword in Phaser states


Recommended Posts

This is not strictly a Phaser thing. This gives context to whatever you assign it and depends on where you call it first. Read about it a bit more here


You could use let for instance, but whatever variable you assign with let for instance in "create" cycle it will only be visible there and not in update or render cycle or wherever else.

If you use this just by it self it will represent the object in context of which it has been called.

It's hard to explain this in the first place so I'd suggest you read tutorials about it. Hope it helps.

Link to comment
Share on other sites

In this link they explain in detail the use of the "this" keyword in javascript:


In my humble opinion (I'm a newbie in javascript and Phaser), your question is more related to javascript than to Phaser framework. Using more time in javascript learning at the end will save you a lot of time when developing in Phaser, and will provide you with other resources that in some cases the framework will not be able to offer.


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...