• Content Count

  • Joined

  • Last visited

About jaymeh

  • Rank

Contact Methods

  • Twitter

Recent Profile Visitors

860 profile views
  1. Hi, I am currently having an issue where my alpha tween on my game isn't working as I expected. I set the tween to happen over 5 seconds however it seems to only take a fraction of the time and ignores the time. Here is my code: var box = this.game.add.graphics(0,0); box.alpha = 0.1; box.moveTo(0, 0); box.beginFill(0x000000); box.drawRect(borderSide, borderTop, (this.game.world.width - borderSide * 2), this.game.world.height); box.endFill(); var fadeTween = this.game.add.tween(box).to({ alpha: 1 }, 5000, "Linear", true); fadeTween.onComplete.add(this._end_game, this); You can see my video attached below for an example of this in action. Thanks, Jamie alpha.mp4
  2. Thanks 8Observer8, Handy tutorial and good to refer to, for the bits I was struggling with.
  3. I see, I think I assumed that restarted the state would reset the variables at the top of the page but I guess those are not setup by Phaser. I guess it would work if I set them up in a global scope then set their default values inside the create method. Thanks, it's a good thing to note. I see, yeah it seems like I place it in the wrong place but didn't notice it while I was debugging. Thanks samid737, appreciate your help on this!
  4. Hi, I have been working on my first full game and decided to try a snake clone. I haven't followed any kind of tutorial and have just been trying to get to grips with the framework. I am however having a few issues and have been stuck for a couple of hours to try and fix a couple of annoying bugs. The first main issue I have with my game is that collisions don't seem to be firing correctly. I have tried to set one up when the head of the snake collides with any of the tail elements which just restarts the game state for testing purposes. This seems to however try to trigger another function which should only happen when a player collides with food. I am guessing I need to setup my collision handlers differently in order to fix this. The other bug is that when a bit of food has been eaten a new sprite it created but just before it does it gets added randomly to somewhere on the screen then disappears but I can't work out why that would be. I setup a git repo of my project so far on github and it can be found here: https://github.com/jaymeh/phaser-snake If someone could offer some advice as to what I can do to fix this I would be very grateful. Thanks
  5. Hi all, I have looked around the forums and googled around for the past hour or so to try and figure out a solution to get graphics to look crisp. I have created 2x versions of my assets and load them in based on a switch statement for device pixel ratio. This is however just causing my sprites to double in size but still be blurry. I tried a few other solutions such as the following: This just seemed to cause my game to half in size on my Retina MBP. I thought that this solution may be ideal: However I get this issue: phaser.js:82051Uncaught TypeError: Cannot set property 'scaleMode' of null At this point I am thinking it may just be best to half the scale of my sprites since this is my first game and I don't use a large amount of assets. I still however don't feel its the best solution and wondered if anyone has any other suggestions or examples of how it can be done? Thanks, Jamie
  6. Perfect, just the answer I was looking for. Thanks for your help.
  7. Hi All, Was wondering if someone could help, I have just started using phaser a few weeks ago and have been relying heavily on the tanks example to try and build my own game. Currently I am having an issue with some code which is supposed to fire a bullet where the rotation of the bullet is off by 90 degrees. // Setup a group for player bulletsgBullets = game.add.group();gBullets.enableBody = true;game.physics.arcade.enable(gBullets);gBullets.createMultiple(30, 'playerBullet', 0, false);gBullets.setAll('anchor.x', 0.5);gBullets.setAll('anchor.y', 0.5);gBullets.setAll('outOfBoundsKill', true);gBullets.setAll('checkWorldBounds', true);cSpacebar.onDown.add(this.fireBullet, this);fireBullet: function() { // Create a bullet element using players position; var bullet = gBullets.getFirstExists(false); bullet.reset(this.player.x, this.player.y); bullet.rotation = game.physics.arcade.accelerateToXY(bullet, this.player.x, this.player.y -10, 200, 200, 200);}Here is an example image of what is happening. I am wanting the sprites to be rotated vertically. I tried to rotate the sprite through the image but this however is strangely causing the same issue. Any help would be greatly appreciated. Thanks, Jaymeh
  8. Ahh that's where I went wrong I was adding a reference to the image I loaded not the bullet object. All the preload stuff gets loaded in a seperate JavaScript class. As with the space bar I was getting confused as I thought it had to be checked that the space had been pressed every frame. Thank you very much for your help .
  9. Hi Dumtard, Thanks for your reply. I have basically created a group and the bullet is object within that group which has physics attached. It may be helpful if I just pasted in my whole JavaScript file since I am not sure if everything is being setup correctly as various tutorials seem to do it differently. var cSpacebar;var cCursorKeys;var gBullets;var gEnemies;var playState = { create: function() { // Setup any functions relating to world this.background = game.add.tileSprite(0, game.world.height, 'background'); this.background.anchor.setTo(0, 1); // ... // Setup the control scheme cSpacebar = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); cCursorKeys = game.input.keyboard.createCursorKeys(); //... // Setup the player object this.player = game.add.sprite(game.world.width/2, game.world.height/2, 'player'); this.player.anchor.setTo(0.5, 0.5); game.physics.arcade.enable(this.player); this.player.body.collideWorldBounds = true; game.camera.follow(this.player); // ... // Setup a group for player bullets gBullets = game.add.group(); gBullets.enableBody = true; game.physics.arcade.enable(gBullets); gBullets.createMultiple(30, 'playerBullet', 0, false); gBullets.setAll('anchor.x', 0.5); gBullets.setAll('anchor.y', 0.5); gBullets.setAll('outOfBoundsKill', true); gBullets.setAll('checkWorldBounds', true); // ... // Setup a group for enemies gEnemies = game.add.group(); gEnemies.enableBody = true; game.physics.arcade.enable(gEnemies); /// gEnemies.createMultiple(10, 'enemy', // ... }, update: function() { // Player Movement Controls if(cCursorKeys.left.isDown) { this.player.x -= 5; }else if(cCursorKeys.right.isDown) { this.player.x += 5; }else{ this.player.x += 0; } if(cCursorKeys.up.isDown) { this.player.y -= 5; }else if(cCursorKeys.down.isDown) { this.player.y += 5; }else{ this.player.y += 0; } cSpacebar.onDown.add(this.fireBullet, this); // ... // Stage Setup - Move Background this.background.y += 2; }, fireBullet: function() { // Create a bullet element using players position; var bullet = gBullets.getFirstExists(false); game.physics.enable(bullet, Phaser.Physics.Arcade); console.log(bullet); bullet.rotation = game.physics.arcade.accelerateToXY('playerBullet'); }};Thanks, Jamie
  10. Hi Everyone, I am currently working on my first game using Phaser but I am having an issue with using accelerateToXY. I am developing a space invaders type game and for the bullet code I am following parts of the tanks example to try and fire a bullet. Here is the line it seems to be stuck on: bullet.rotation = game.physics.arcade.accelerateToXY('playerBullet', this.player.x, this.player.y + 10, 40, 100, 100);However when trying to fire the bullet I get the following error message in the console from phaser.min.js: "Uncaught TypeError: Cannot read property 'acceleration' of undefined" If anyone could offer any assistance with this issue it would be greatly appreciated Thanks, Jaymeh Edit: I am currently running phaser version 2.0.6