Jump to content

PMayhem

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by PMayhem

  1. Can't say I notice any performance difference, but I prefer using groups as it keeps the code looking tidy. I was pleasantly surprised with collision detection worked with groups. this.game.physics.arcade.collide(this.player, grpEnemies, this.playerEnemyCollide, null, this); playerEnemyCollide: function(player, enemy){ //Player Enemy Collision } }
  2. anyone? dust? anyone? Or is there a way I can debug a single snowman and see all of it's properties, not just the standard positioning but the custom properties?
  3. I'm stuck with 2 last issues with my first platformer game. ***EDIT*** Here's a link for reference http://projectmayhem.co.uk/sandbox/santa/santa.html I can't get all of my snowmen to shoot, and also I can't seem to remove the 'kill' animation when a snowman dies. Any suggestions would be really helpful. I'm creating enemy snowmen and adding them to a group So I'm defining and creating the snowmen group then adding each snowman in the create with grpSnowmen = this.game.add.group();this.spawnSnowman(800,200, 'snowman1');Which calls the following, adding a new snowman to the group spawnSnowman: function(x,y,name){ var snowman = this.game.add.sprite(x,y, 'snowman'); this.game.physics.arcade.enable(snowman); snowman.name = name; snowman.isAlive = true; snowman.health = 1; snowman.pathcount = 1; snowman.enableBody = true; snowman.body.gravity.y = 500; snowman.body.collideWorldBounds = true; snowman.animations.add('walking_left', [0,2], 6, true); snowman.animations.add('walking_right', [1,3], 6, true); grpSnowmen.add(snowman); return snowman; } Next, in the update, I'm cycling through the group and if the snowman is alive, I'm updating it's path and calling fire functions ala: grpSnowmen.forEach(function(snowman) { if(snowman.isAlive){ this.snowmanPath(snowman); this.enemyShoots(snowman); } }, this); All of the snowmen move correctly, however only the very first snowman fires Here are the snowmanPath and EnemyShoots functions snowmanPath: function(enemySnowman) { if (this.pathCounter < 325) { enemySnowman.animations.play('walking_right'); enemySnowman.body.velocity.x = 100; enemySnowman.facingEnemy = 'right'; } else { enemySnowman.animations.play('walking_left'); enemySnowman.body.velocity.x = -100; enemySnowman.facingEnemy = 'left'; } } enemyShoots: function(thisSnowMan) { obj = thisSnowMan; if (this.shotTimerEnemy < this.game.time.now && thisSnowMan.isAlive == true) { this.shotTimerEnemy = this.game.time.now + 3000; if (thisSnowMan.facingEnemy == 'right') { this.snowball = snowballs.create(thisSnowMan.body.x + thisSnowMan.body.width / 2 + 45, thisSnowMan.body.y + thisSnowMan.body.height / 2 + 5, 'snowball'); } else { this.snowball = snowballs.create(thisSnowMan.body.x + thisSnowMan.body.width / 2 - 40, thisSnowMan.body.y + thisSnowMan.body.height / 2 + 5, 'snowball'); } this.game.physics.enable(this.snowball, Phaser.Physics.ARCADE); this.snowball.body.gravity.y = 300; this.snowball.body.bounce.y = 10; this.snowball.outOfBoundsKill = true; this.snowball.anchor.setTo(0.5, 0.5); this.snowball.body.velocity.y = -160; if (thisSnowMan.facingEnemy == 'right') { this.snowball.body.velocity.x = 400; } else { this.snowball.body.velocity.x = -400; } } }
  4. *UPDATE* http://projectmayhem.co.uk/sandbox/santa/santa.html Sorry about the blank screen, it was probably just taking a while to load but I've figured out splash/loading screens now. New version is now online, still need to iron out a few bugs, the enemy die animation is not clearing properly. And also I've yet to figure how to get all snowmen to fire snowballs simultaneously. Currently only the first snowman fires. It's not throwing any errors and as far as I'm away it should be looping through each snowman in the group grpSnowmen and calling a shoot function.. hmm weird.
  5. Is this at all possible? I originally managed to achieve the effect when I loaded in the background as one single image. But now I'm using tilemaps and adding to a layer with addTilesetImage I can't seem to get any movement there. It's just a simple x -= 0.5; //When moving right x += 0.5; //When moving left Here's how I'm currently loading the background layer: game.load.image('sky', 'assets/parallax-bg.png'); game.load.tilemap('map', 'assets/tilemaps/level1.json', null, Phaser.Tilemap.TILED_JSON); this.map = this.add.tilemap('map'); this.map.addTilesetImage('background_spritesheet', 'sky'); bgtile = this.map.createLayer('backgroundLayer'); Then I've tried the following in the update() within my if(cursors.left.isDown) to try and get some movement bgtile.tilePosition.x += 0.5; Oh, and here's a link of the WIP if anyone's interested! http://projectmayhem.co.uk/sandbox/santa/santa.html
  6. http://projectmayhem.co.uk/sandbox/santa/santa.html So I wanted to try my hand at some gaming dev. My 3 yr old son has just started getting the hang of some simple platformers so I decided to make something seasonal for him. Got a long list of things to finish but so far I've got the hang of the fundamentals, tilemaps/spritesheets/collisions. Things to do: loading and start screen object/present collection and points scoring detect snowball-player and enemy-player collisions determine best sizing/ratio (sorry it's so small, but works best that way with the chrome debugger panel open) parallax background - I had this working initially when the background was one huge image, since I moved across to using a tileset layer I cannot seem to get the same effect. scoreboard/leaderboard - something with a Mysql db that won't take me long to knock up. +add more levels!
  7. Strange, Have you tried de-bugging and see if simple collisions work first ie: game.physics.arcade.collide(grpAliens, grpBullets);
  8. I think it should be game.physics.arcade.collide(grpAliens, grpBullets, hitAlien); I think collide accepts 2 more parameters, whether they're required or not I don't know. Will have to look at the docs.
  9. Not sure about the tiles node in the Json file as I've now overwritten it with a working one. I'll see if I can re-create the error and post the message. I may have inadvertently jumped the gun on blaming Phaser for the problem! Let me grab the error message again to confirm.. In the meantime, I'm now struggling with getting a background layer to repeat with: game.add.tileSprite(0, 0, 1024,1024, 'sky');
  10. Hey everyone, Thanks for the replies. After a lot of trial and error, I updated to Phaser 2.2.1 which gave a few more hints in the dev console. Turns out Phaser can't handle more than 1 spritesheet. And I had 2 loaded in through my Tiled project. (Doh!)
  11. Hi All, New to phaser as I wanted to try my hand at game dev. I write business apps with ASP.NET Ajax so the odd bit of javascript doesn't scare me. Anyhow, I've been struggling for an entire evening trying to load a Tiled generated tilemap. json file is all present and correct and I've tried a variety off different tutorials/examples but al I get in the dev console is: 'Uncaught TypeError: Cannot read property '2' of undefined' Here's what I'm trying to use var game = new Phaser.Game(800, 600, Phaser.AUTO, 'mapPhaser', { preload: preload, create: create, update: update }); function preload() {//Load the spritesheet for the tilemap game.load.image('tileset', 'assets/sheet.png');//Load the tilemap file game.load.tilemap('map', 'assets/tilemaps/level1.json', null, Phaser.Tilemap.TILED_JSON);} var map;var layer; function create() { map = this.add.tilemap('map'); map.addTilesetImage('tiles_spritesheet', 'tileset'); layer = map.createLayer('backgroundLayer'); layer.resizeWorld(); }function update() { }
×
×
  • Create New...