wich word "this" replace in this line ?

Recommended Posts


in this snippet wich object "this" replace at this line, if i would write this  :D without "this" what must i write  :

        playerPapers5 =

the  part of the snippet :

var theGame = function(game){

	playerPapers5 = null

theGame.prototype = {
	create: function(){

		playerPapers5 =



Share this post

Link to post
Share on other sites

according to this code it means the game

menuState = {
    create: function() {, 0, 640, 360);
        var b = (game.add.image(0, 0, "menubg"), game.add.image(230, 200, "whiteplanemenu"));
        b.anchor.set(.5, .5);
        this.playbutton = game.add.button(428, 183, "playgamebutton", this.start),
        this.instructionbutton = game.add.button(428, 237, "instructionbutton", this.instruction),
        this.aboutbutton = game.add.button(573, 237, "aboutbutton", this.about),

game = new Phaser.Game(640, 360); = {
    score: 0,
    bgm: new Object,
    gameoverbgm: new Object,
    ingamebgm: new Object,
    background: game.rnd.between(0, 4)
game.state.add("boot", bootState),
game.state.add("load", loadState),
game.state.add("menu", menuState),


Share this post

Link to post
Share on other sites

The "this" in the first example refers to the current Phaser.State. The fact that you can call the same way that you can call this.add is dictated by the fact that they both refer to the same thing (i.e. the state has a reference to an instance of Phaser.GameObjectFactory; the game has a reference to that very instance - and it's the same for a lot of other things).

Share this post

Link to post
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.