Jump to content

Collider for whole group


devbruce
 Share

Recommended Posts

Hey guys,

im new to Phaser framework and I've got a problem.

I try to put the stars from the tutorial on top of each other by doing this:

 

stars = this.physics.add.group();
//this.physics.add.collider(player, stars, hitStars, null, this);
this.physics.add.collider(stars,stars);
this.physics.add.collider(stars, platforms);
makeStars();

now if I do this the Stars fall in each other, only two Stars are on top of each other. If I change the order of the two colliders the Stars fall through the ground and still only two Stars stay on top of each other.

This is my makeStars() function:

function makeStars(){
		if (this.stars) {
			this.stars.clear(true);
		}
		if (this.stars) {
			//stars.create(700, 497, 'star').body.velocity.x = 0;
			var numberofStars = randomNumber(1, 10);
			for (var i = 0; i < numberofStars; i++) {
				stars.create(700, -i * 50/*497*/, 'star').body.velocity.x = -150;
			}
		}
	}

 

I really hope you can help me with this !

Thanks in advance

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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