Jump to content

Add gravity to a sprites in group over time


illscode
 Share

Recommended Posts

Hey all, I'm building a little christmas game... I've attached a screenshot, got a set up of conveyer belts (sorta Donkey Kong-ish).  I've created a group of sprites (giftgroup) hiding behind the pipe in the top right corner. My goal is to add gravity to each sprite over time, maybe 1 every half second so that gifts keep pouring out of the pipe. Should I be trying to do this in the update: function() or is there a way to add the gravity when creating the group but somehow delay the creation of each sprite? I'm a phaser newbie still and novice javascripter so any help with this is appreciated!

	buildGifts: function(){					this.giftgroup = this.add.group();			this.giftgroup.enableBody = true;       		for(var i=0; i<this.totalGifts; i++){									var g = this.giftgroup.create(1000, 80, 'blueGift', 0000);								g.anchor.setTo(0.5,0.5);				g.body.moves = true;				g.animations.add('gifted', Phaser.Animation.generateFrameNames('gift', 0, 0, '', 4), 30, true);				this.game.physics.arcade.enable(g);				g.body.bounce.y = 0.2;			//	g.body.gravity.y = 1500;				g.body.velocity.x = 0;				g.inputEnabled = true;				g.events.onInputDown.add(this.destroyGift, this);						}

post-8198-0-03943000-1447185625.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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