frokenstein

Members
  • Content Count

    39
  • Joined

  • Last visited

About frokenstein

  • Rank
    Advanced Member
  1. I've tried everything I could think of in the shutdown() function but when I restart a game I cannot get it to restart in the same state it was in when I first loaded it in my browser. When my game ends there is a prompt to restart and when the user clicks the mouse, this function is called: this.game.state.start('Game', true, false);It seems to do its job but for whatever reason the alien ship sprite and its accompanying map sprite are invisible despite the fact that I can verify they're created. Not incidentally, this is the same function that starts the game the first time. I am perplexed why the exact same function wouldn't work the same way when called a second time. You can see it in action here: http://joelsaxton.github.io/starpatrol/ I've tried about six different ways to shutdown() the game but to no avail. My guess is the sprites are not being added to the game object (or something?) but I have to wonder why the same function which sets up the game would do it differently the second time it runs.
  2. Figured it out. this.engineBuyIcon.inputEnabled = true;this.engineBuyIcon.events.onInputDown.add(this.buyItem, this);
  3. What is the simplest way to do this? Right now I am binding a function whenever the mouse is clicked: game.input.onDown.add(this.clickOnItem, this);This function figures out the x,y location of the click but what is the easiest way to determine if it is above a particular icon? Do I need to write an overlap function for every single icon it may overlap/collide with?
  4. This seems to have worked. Strange, though: this.game.add.existing wasn't needed for my other sprites.
  5. This is a game that used to work. I moved some of the vars into the player object because that's where they belong. But I believe I've created a scoping problem or something related. The player sprite is now invisible and physics is no longer enabled. I cannot see where the issue is. There is a map sprite which is part of the player sprite and that is visible. It's very odd. I think it's something simple but I cannot seem to find the culprit: The player gets instantiated as follows: this.player = new Player(this, this.earth.x, this.earth.y);The player object looks like this: var Player = function(main, x, y, frame){this.playerScale = main.GAME_SCALE;var key = 'player';Phaser.Sprite.call(this, main.game, x, y, key, frame);this.anchor.setTo(0.5);this.scale.setTo(this.playerScale * 1.6);this.MAXHEALTH = 100;this.MAXCHARGE = 100;this.MAXTURNINCREMENT = 0.1;this.MAXTURNRATE = 4;this.MINTURNRATE = 0.8;this.WARP_DISCHARGE = 0.2;this.SHIELD_DISCHARGE = 4;this.MAXVELOCITY = this.playerScale * 3500;this.WARPVELOCITY = this.playerScale * 16;this.MAXTHRUST = this.playerScale * 50;this.health = this.MAXHEALTH;this.charge = this.MAXCHARGE;this.thrust = this.MAXTHRUST;this.turnRate = 0;this.maxTurnRate = this.MAXTURNRATE;this.turnIncrement = this.MAXTURNINCREMENT;this.maxVelocity = this.MAXVELOCITY;this.shieldStrength = this.MAXCHARGE;this.warpDrive = this.MAXCHARGE;this.warpModifier = 5;this.isAlive = true;this.isReloaded = true;this.isBurning = false;this.isWarping = false;this.isShielded = false;main.game.physics.arcade.enableBody(this);this.body.bounce.set(0.8);this.checkWorldBounds = true;this.body.collideWorldBounds = true;this.begin = true;this.nukes = 0;this.missiles = 0;this.hasShields = false;// Set player mapthis.map = main.game.add.sprite(main.width - main.mapSize - main.mapOffset + parseInt(this.x * main.mapGameRatio), parseInt(this.y * main.mapGameRatio) + main.mapOffset, 'playermap');this.map.fixedToCamera = true;this.map.anchor.setTo(0.5);this.map.scale.setTo(2);// Set player animationsthis.animations.add('drift', [0]);this.animations.add('shield', [1]);this.animations.play('drift', 20, true);this.map.animations.add('tracking', [0,1]);this.map.animations.play('tracking', 10, true);};Player.prototype = Object.create(Phaser.Sprite.prototype);Player.prototype.constructor = Player;Player.prototype.onRevived = function() {this.health = this.MAXHEALTH;this.turnIncrement = this.MAXTURNINCREMENT;this.maxVelocity = this.MAXVELOCITY;this.maxTurnRate = this.MAXTURNRATE;this.thrust = this.MAXTHRUST;this.isBurning = false;this.warpDrive = this.MAXCHARGE;};I have console logged this object and there are no NaN or undefined properties, so it seems like everything is getting in there, but the player ship does not appear and is no longer supporting physics. What stupid thing have I done here? You can see the game here: joelsaxton.github.io/starpatrol The repo is here: https://github.com/joelsaxton/starpatrol PS - do you have a paid support option yet?
  6. Is it possible to make a scrolling game using the isometric plugin? Or is it static? I am curious if there are any examples out there. Thanks
  7. I make a heat seeking nuke in my game. I utilize this function to help it track its target: this.game.physics.arcade.angleBetween(nuke, this.alien)When the nuke is launched and the target is to the right of it, it tracks fine. But if the target is to the left, the nuke just oscillates slightly and doesn't turn all the way around to move toward its target. Does angleBetween not take this into account?
  8. I am trying to chain tweens then run an onComplete once the final tween runs. Unfortunately Phaser ignores the fist tween. Any ideas why? var tween = this.add.tween(this.alien).to({x: 500, y: 500}, 3000, Phaser.Easing.Linear.None).to({x: 0, y: 0}, 3000, Phaser.Easing.Linear.None).start();tween._lastChild.onComplete.add(function(){this.alien.isAttacking = true;}, this);Once the tween is triggered the sprite goes to x: 0, y: 0 and completely ignores the first directive to go to x: 500, y: 500. I am using Phaser 2.2.0 RC7 and I'm wondering if there is a bug here.
  9. Well, it was working. I broke the fiddle. Working on it...
  10. You can also see it in its full glory here (with debugger on): http://joelsaxton.github.io/starpatrol/ I created a fiddle but it is very stripped down, and, unfortunately, it works: http://jsfiddle.net/joeljoelbinks/v0ojvuh9/ I will need to keep adding stuff back until I can get it to fail. This is a really weird problem.
  11. Two places. First at the beginning of the game. This creates an alien that works. ...and in the update() function. If an alien was killed, after a timer event a new one is created here: if (this.alienTimer < this.game.time.now) {this.alienTimer = this.game.time.now + this.alienInterval;if (this.aliens.countLiving() < this.TOTALALIENS) {this.createAlien();}}I have verified the second alien is created, but it has NaN for rotation, x, y, etc. But its health is back to 100, its alive is true, and the other indications if it being alive look correct. It just never appears on the screen. It seems to be some kind of ghost object but I cannot see what is missing.