Jump to content

Uncaught ReferenceError?


ZRT
 Share

Recommended Posts

Hey guys, it's me again. :)

 

I already posted what I'm doing in a different thread, but this time the problem is something else.

 

I have this, which works fine with a slightly different code (without using states and object literals), but here it gives me:

 

Uncaught ReferenceError: resetTop is not defined

 

I saw some examples and haven't seen the functions being defined someplace else.  If I change this.ob.events.onOutOfBounds.add(resetTop); to this.ob.events.onOutOfBounds.add(this.resetTop); it cannot call the reset method. Any ideas? Thanks.

 

EDIT: I'm using Phaser 1.1.3

Game.Play.prototype = {  create: function() {    // create player    this.player = game.add.sprite(50, 100, 'player');    this.player.body.gravity.y = 7;    this.player.outOfBoundsKill = false;       // create obstacles    this.obTop = game.add.group();    this.ob = this.obTop.create(this.game.world.width + Math.random() * 500, 0, 'obstacle');    this.ob.events.onOutOfBounds.add(resetTop);    this.ob.body.velocity.x = -500;  },  update: function() {    if (this.game.input.activePointer.isDown) {      this.player.body.velocity.y = -200;    }  },  resetTop: function() {    this.ob.reset(this.game.world.width + Math.random() * 500, 0, 'obstacle');    this.ob.body.velocity.x = -400;  },};
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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