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

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