Jump to content

Problem wiht add elements to group


P4nch0
 Share

Recommended Posts

Hi!

 

I have a problem with add my elements to gruop. I want to add it because i must cinfigure what will be do after collide element with player.

 

 

This is my function where after click on screen can add elements from equipment to the game screen:

 createeq: function(){                 this.eqgroup = this.game.add.group();                       if (typ1==0){        this.cup=this.add.sprite(this.input.activePointer.x + this.camera.x,this.input.activePointer.y + this.camera.y, przedmiotwybrany);        this.cup;                this.eqgroup.add(this.cup);        this.eqgroup.enableBody = true;                }        else{}  },

I want to create group to make collide with player like that:

  update: function() {    //collision    this.game.physics.arcade.overlap(this.player, this.eqgroup, this.eqitemadd, null, this);   ...

And function after collide:

  eqitemadd: function(){  console.log('add');  },

And there is a problem, when my player collide with element dont do anything.

Anyone can help?

 

You can see my project on:

 

http://lifetime.cba.pl

Login : test

Pw: test

 

And them click "graj".

 

Thanks in advance!

 

Link to comment
Share on other sites

Ok i have a solution, problem was bacause only the second added element was colliding.

 

So i must add "this.game.physics.arcade.enable(this.stol);"

createeq: function(){this.eqgroup = this.game.add.group();if (typ1==0){this.cup=this.add.sprite(this.input.activePointer.x + this.camera.x,this.input.activePointer.y + this.camera.y, przedmiotwybrany);this.cup;this.game.physics.arcade.enable(this.stol);this.eqgroup.add(this.cup);this.eqgroup.enableBody = true;}else{}},
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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