metalslug87

Members
  • Content count

    19
  • Joined

  • Last visited

About metalslug87

  • Rank
    Member

Recent Profile Visitors

384 profile views
  1. Phaser Hex grid engine

    Thanks but is there any working example of the engine, something like sandbox ? or an example of very simple mini-game on hex ?
  2. Phaser Hex grid engine

    Hello, I'm searching for Hex grid engine to make Battle Isle (DOS) clone in Phaser.js, if somebody can help me with that I'll be very gratefull cause I've found only this link which is broken -> http://www.html5gamedevs.com/topic/12546-super-simple-hex-tile-grid-demo/ Maybe there is a Phaser Hex Grid addon with documentation that I can't find ?
  3. world bounds problem on moveToXY method

    Solved, I've replaced: this.playerX = this.input.activePointer.x; this.playerY = this.input.activePointer.y; to: this.playerX = this.input.activePointer.worldX; this.playerY = this.input.activePointer.worldY;
  4. world bounds problem on moveToXY method

    I just want to move the player on the whole map not just in the game box (400px x 600px), the whole map is about 12000px x 5000px, these lines of code could be helpfull to describe my problem: var GameState = function(game) { }; GameState.prototype.preload = function() { this.game.load.tilemap('map-1', 'assets/map-1.json', null, Phaser.Tilemap.TILED_JSON); this.game.load.image('tiles-1', 'assets/tileset-1.png'); this.game.load.spritesheet('player', 'assets/player.png', 10, 14); this.game.load.image('playerBullet', 'assets/playerBullet.png'); }; GameState.prototype.create = function() { this.map; this.tileset; this.layer; this.player; this.bg; this.rapidKeyPressBlock = false; this.playerX; this.playerY; this.game.physics.startSystem(Phaser.Physics.ARCADE); this.map = this.game.add.tilemap('map-1'); this.map.addTilesetImage('tileset-1', 'tiles-1'); this.layerDecorations = this.map.createLayer('decorations'); this.layer = this.map.createLayer('map'); this.player = this.game.add.sprite(200, 250, 'player'); this.game.physics.enable(this.player, Phaser.Physics.ARCADE); this.player.body.setSize(10, 14, 0, 0); this.game.camera.follow(this.player); this.playerBullets = this.game.add.group(); this.playerBullets.enableBody = true; this.playerBullets.physicsBodyType = Phaser.Physics.ARCADE; this.playerBullets.setAll('checkWorldBounds', true); this.playerBullets.setAll('outOfBoundsKill', true); this.layer.debug = true; this.shootButton = this.game.input.keyboard.addKey(Phaser.Keyboard.Z); this.game.world.setBounds(0, 0, 12000, 5000); this.layer.resizeWorld(); //this.game.world.resize(12000, 12000); }; GameState.prototype.update = function() { if (this.shootButton.isDown && this.rapidKeyPressBlock == false) { this.playerShootButton(); this.rapidKeyPressBlock = true; this.game.time.events.add(Phaser.Timer.SECOND * 0.2, function() { this.rapidKeyPressBlock = false; }, this); }; //player movement this.player.body.velocity.x = 0; this.player.body.velocity.y = 0; if (this.game.input.activePointer.isDown) { this.playerX = this.input.activePointer.x; this.playerY = this.input.activePointer.y; console.log("X: " + this.playerX + " Y: " + this.playerY); } if (this.game.physics.arcade.distanceToXY(this.player, this.playerX, this.playerY) > 5) { this.game.physics.arcade.moveToXY(this.player, this.playerX, this.playerY, 100, 0); } }; // end UPDATE GameState.prototype.playerShootButton = function() { this.playerBullet = this.playerBullets.create(this.player.position.x + 8, this.player.position.y + 5, 'playerBullet'); this.playerBulletX = this.input.activePointer.x + this.game.rnd.integerInRange(-15, 15); this.playerBulletY = this.input.activePointer.y + this.game.rnd.integerInRange(-15, 15); game.physics.arcade.moveToXY(this.playerBullet, this.playerBulletX, this.playerBulletY, 350, 0); this.playerBullet.body.outOfBoundsKill = true; }; GameState.prototype.render = function() { // this.game.debug.bodyInfo(this.player, 16, 24); }; var game = new Phaser.Game(400, 600, Phaser.AUTO, 'game'); game.state.add('game', GameState, true);
  5. world bounds problem on moveToXY method

    Hello :), I have problem with world bounds, when the player goes right he reaches the invisible barrier and he can't go through. He can't even shoot behind this barrier. I am attaching the code with test game, please help me, I've read the phaser docs and I can't find any usefull info about my problem. Game controls: Z - shoot Left Mouse Click - walk phaser-example.zip
  6. animation onComplete callback

    Yes! addOnce worked like a charm! Thank you very much !
  7. animation onComplete callback

    Hello, I've problem with animation complete callback, when fired first time it's ok. On next function executions it's adding additional console.log value "nut fired". So the JS console output looks like that (it's adding additional execution of animation callback): nut fired! -> nut fired! (3) -> nut fired! (6) -> nut fired! (10) ... function squirellThrowNut () { for (var i = 0; i < squirells.length; i++) { squirells.children[i].animations.play('throw'); squirells.children[i].animations.currentAnim.onComplete.add(function () { for (var i = 0; i < squirells.length; i++) { console.log('nut fired!'); } }, this); }; } Please help me, I can't figure it out.
  8. destroy() on group children error

    thanks! I've made a correction (undefined typeof condition) and it's working fine if (boomerangReturn == true && typeof boomerangBullets.children[0] != "undefined") { game.physics.arcade.moveToXY(boomerangBullets.children[0], player.body.position.x, player.body.position.y, 200, 0); if(game.physics.arcade.distanceBetween(player, boomerangBullets.children[0]) < 30) { boomerangBullets.children[0].destroy(); } };
  9. player body full overlap inside ladder tile

    Thanks! I will try this out
  10. destroy() on group children error

    hello, I have an error when using destroy() on group.children[0] function create() { boomerangBullets = this.game.add.group(); boomerangBullets.enableBody = true; boomerangBullets.physicsBodyType = Phaser.Physics.ARCADE; boomerangBullets.setAll('checkWorldBounds', false); boomerangBullets.setAll('outOfBoundsKill', true); } function update() { if(game.physics.arcade.distanceBetween(player, boomerangBullets.children[0]) < 30) { boomerangBullets.children[0].destroy(); } } here is an error screenshot --> http://prntscr.com/cnea7s Please help me, the kill() method is working fine but I need to completely destroy the group children element.
  11. Hello :), is it possible to detect an event when whole player body intersects with ladder tile ? Not only part of it ? (see the attachment below) I am also searching for effective ladder climb example in some phaser platform game
  12. Phaser platform ladder aka lode runner

    thanks :), do you know how to detect an event when whole player body intersects with ladder tile ? Not only part of it ? Like in the attachment here below:
  13. moving player by moveToXY canvas hidden barrier

    I've found solution, thank you for your answers if (this.game.input.activePointer.isDown) { this.playerX = this.input.worldX; this.playerY = this.input.worldY; //console.log("X: " + this.playerX + " Y: " + this.playerY); }
  14. moving player by moveToXY canvas hidden barrier

    This is the whole code, maybe someone can figure it out var GameState = function(game) { }; GameState.prototype.preload = function() { this.game.load.spritesheet('dwarf', 'assets/dwarf.png', 20, 30); }; GameState.prototype.create = function() { this.map; this.tileset; this.layer; this.player; this.cursors; this.bg; this.playerX; this.playerY; this.game.physics.startSystem(Phaser.Physics.ARCADE); this.map = this.game.add.tilemap('map-1'); this.map.addTilesetImage('tileset-1', 'tiles-1'); this.map.setCollisionByExclusion([ 1 ]); this.map.setCollisionByExclusion([ ], true, 'rocks'); this.layer = this.map.createLayer('map'); this.layerRocks = this.map.createLayer('rocks'); this.player = this.game.add.sprite(200, 250, 'dwarf'); this.game.physics.enable(this.player, Phaser.Physics.ARCADE); //this.player.body.collideWorldBounds = true; this.player.body.setSize(20, 30, 0, 0); this.player.frame = 0; this.game.camera.follow(this.player); this.layer.resizeWorld(); this.layer.debug = true; this.cursors = this.game.input.keyboard.createCursorKeys(); }; GameState.prototype.update = function() { //player movement if (this.cursors.left.isDown) { this.player.body.velocity.x = -150; } else if (this.cursors.right.isDown) { this.player.body.velocity.x = 150; } if (this.cursors.up.isDown) { this.player.body.velocity.y = -150; } else if (this.cursors.down.isDown) { this.player.body.velocity.y = 150; } this.player.body.velocity.x = 0; this.player.body.velocity.y = 0; if (this.game.input.activePointer.isDown) { this.playerX = this.input.activePointer.x; this.playerY = this.input.activePointer.y; } if(this.game.physics.arcade.distanceToXY(this.player, this.playerX, this.playerY) > 5) { console.log("playerX: " + this.playerX + " --- playerY: " + this.playerY); this.game.physics.arcade.moveToXY(this.player, this.playerX, this.playerY, 60, 0); } }; // end UPDATE GameState.prototype.render = function() { }; var game = new Phaser.Game(300, 400, Phaser.AUTO, 'game'); game.state.add('game', GameState, true);
  15. Phaser platform ladder aka lode runner

    hello, I am searching for effective way of ladder climb for player like in old Loder Runner game for NES :). I already have only simple script in Update function, if the player overlaps 2 hidden objects on both sides of the ladder he gains the ability to climb. In fact it's hard to accurate get the player at the center point of ladder to climb it. Any Ideas ? if (playerTouchLeftLadder && playerTouchRightLadder) { console.log('overlaps ladder'); if (cursors.up.isDown) { player.body.velocity.y = -75; playerGravity = 0; player.frame = 9; onLadder = true; }else if (cursors.down.isDown) { player.body.velocity.y = 75; playerGravity = 0; player.frame = 9; onLadder = true; }else if (playerJumpState == false){ player.body.velocity.y = 0; } }else{ playerGravity = 500; onLadder = false; };