illscode

Members
  • Content Count

    5
  • Joined

  • Last visited

About illscode

  • Rank
    Newbie

Contact Methods

  • Twitter
    @jf_media

Recent Profile Visitors

833 profile views
  1. Question... is it possible to change up the sprites or key used by a particle emitter once they have been set.... have tried... this.emitter1.forEach(function(particle){ particle.loadTexture(myNewKey);}, this); to no avail....
  2. I am doing something similar and pushing 14 items into the reel group.... Still new to phaser.js so bare with me please. I'm having trouble with the movement... Im getting the desired effect with the code below but am wondering if it's a mistake or is inefficient to be doing it this way. I'm checking a boolean in the update() function. create: function() { this.gameScreen; this.handle; this.bounds; this.spacebar; this.reel1; this.reel2; this.reel3; this.spinning = false; var items = ['cherry', 'plum', 'bell', 'clover', 'lemon', 'coin', 'bar', 'apple', 'heart', 'grapes', 'diamond', 'orange', 'shoe', 'seven', 'melon']; // create the reels this.reel1 = this.add.group(); // first reel. this.reel2 = this.add.group(); this.reel3 = this.add.group(); // push items into the reels for(var i = 0; i < 14; i++){ this.reel1.create(133, i * 147 +3, items[game.rnd.integerInRange(0,14)]); this.reel2.create(328, i * 147 +3, items[game.rnd.integerInRange(0,14)]); this.reel3.create(522, i * 147 +3, items[game.rnd.integerInRange(0,14)]); } // align the reels vertically to their spots this.reel1.y = 267; this.reel2.y = 267; this.reel3.y = 267; this.gameScreen = this.add.sprite(0, 0, 'game-screen'); this.bounds = new Phaser.Rectangle(815, 0, 149, 368); this.handle = this.add.sprite(815, 0, 'handle'); this.handle.inputEnabled = true; this.handle.anchor.set(0); this.handle.input.enableDrag(); this.handle.events.onDragStart.add(this.onDragStart, this); this.handle.events.onDragStop.add(this.onDragStop, this); this.handle.input.boundsRect = this.bounds; this.spacebar = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); this.spacebar.onDown.add(this.spacebarHandle, this); this.spacebar.onUp.add(this.spacebarHandleUp, this); }, spacebarHandle: function(){ this.add.tween(this.handle).to( { y: 150 }, 100, Phaser.Easing.Linear .Out, true); }, spacebarHandleUp: function(){ this.add.tween(this.handle).to( { y: 0 }, 500, Phaser.Easing.Bounce.Out, true); this.spinReels(); }, onDragStart: function(){ console.log("lever pulling down"); }, onDragStop: function(){ this.spinReels(); this.add.tween(this.handle).to( { y: 0 }, 500, Phaser.Easing.Bounce.Out, true); }, spinReels: function(){ this.time.events.add(Phaser.Timer.SECOND * 1.5, this.stopReels, this); this.spinning = true; }, stopReels: function(){ console.log("timer stopped"); this.spinning = false; this.reel1.y = 267; this.reel2.y = 267; this.reel3.y = 267; }, update: function() { if(this.spinning){ this.reel1.y -= 25; this.reel2.y -= 30; this.reel3.y -= 35; if(this.reel1.y <= -1680){ this.reel1.y = 267; } if(this.reel2.y <= -1680){ this.reel2.y = 267; } if(this.reel3.y <= -1680){ this.reel3.y = 267; } } } can be viewed at this url: test slot machine (will have to advance to game in the project template i'm using)
  3. Hey all, figure it out with the info on this link: http://www.html5gamedevs.com/topic/2933-how-to-add-delays-in-phaser/
  4. 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); }
  5. 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); }