Jump to content

Adding sprite group over time


Recommended Posts

Hi All, phaser newb, novice js


I'm trying to build a little christmas game, sort donkey kong-ish, with some gifts that go along some conveyer belts into santa's bag (attached a pic). I'm creating a group of gift sprites behind the pipe in the top right. I want to add gravity to each one but over time so they stream out of the pipe in sequence. Would you do this in the update: function() . Is there a way to create the sprites over time and add them to the group? Can your add a delay somehow?


cheers for any advice/help in advance 


here's my js for the group

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);						}


Link to comment
Share on other sites


  • Recently Browsing   0 members

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