Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Getting the name of an object "class"


fran
 Share

Recommended Posts

Hello, I'm trying to define a few objects with their names + properties using classes.

I can have new Goals at creation, however I'm stuck with prototypes.

So far it's:

 

//***************** OBJECTSfunction Goal(nombre, posX, posY){	this.nombre = nombre;	this.posX = posY;	this.posY=posY;	//console.log ('nombre: '+ this.nombre+ ' pos x: '+this.posX);	this.sp = game.add.sprite(posX,posY, 'bola');	game.physics.enable(this.sp, Phaser.Physics.ARCADE);	this.sp.body.immovable = false;    this.sp.body.collideWorldBounds = true;    this.sp.body.bounce.setTo(1, 1);	this.sp.inputEnabled = true;	this.sp.events.onInputDown.add(listener1, this);		/*this.listener1 = function(){		console.log (this.name + 'was cliked!');	}*/}Goal.prototype.listener1 = function() {	console.log (this.name + 'was cliked!');}

My goal was to know which object was clicked (using listener1).

I get a console message:

ReferenceError: listener1 is not defined

Thanks for the patience and the advice on how to fix this.

regards.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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