Search the Community

Showing results for tags 'moving tiles'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. anthkris

    Correct Player Position

    Howdy all, I have another question. I'm making an endless runner with the method of moving the tiles to the left and assigning the player an equal and opposite velocity so that it stays in the same place. The problem is that the player doesn't stay in the same place. I've added a velocity of 0 on jump, so the problem isn't that the player is jumping forward. There are just almost imperceptible little movements (I've logged out the player.x during the course of the game and it will move back and forth 5 or 10 pixels) which sometime snowball into big issues where the player hits the left edge of the screen. I haven't been able to isolate the root cause of the problem. The player can collect coins, hearts, and can hit enemies, however, I'm checking overlap on each of these, not collide. Here is the update function in my Game.js: update: function() { /* COLLISION WITH POOLS */ if (this.player.alive) { this.platformPool.forEachAlive(function(platform, index) { this.game.physics.arcade.collide(this.player, platform, this.hitWall, null, this); this.enemiesPool.forEachAlive(function(enemy, index) { this.game.physics.arcade.collide(enemy, platform); }, this); // update floor tile speed constantly platform.forEach(function(floor) { floor.body.velocity.x = -this.levelSpeed; }, this); //check if platform needs to be killed if(platform.length && platform.children[platform.length - 1].right < 0) { platform.kill(); } }, this); // update coin and life sprite speed constantly this.coinsPool.forEachAlive(function(coin) { coin.body.velocity.x = -this.levelSpeed; }, this); this.lifePool.forEachAlive(function(life) { life.body.velocity.x = -this.levelSpeed; }, this); this.game.physics.arcade.overlap(this.player, this.coinsPool, this.collectCoin, null, this); this.game.physics.arcade.overlap(this.player, this.lifePool, this.collectLife, null, this); this.game.physics.arcade.overlap(this.player, this.enemiesPool, this.hurtPlayer, null, this); this.game.physics.arcade.collide(this.enemiesPool, this.projectilesPool, this.killEnemy, null, this); this.processDelayedEffects(); /* CHECK PLAYER BOOLEANS */ if (this.player.body.touching.down && !this.isHit && !this.isShooting) { this.player.play('running'); this.player.body.velocity.x = this.levelSpeed; } if (!this.player.body.touching.down) { this.player.body.velocity.x = 0; } if (!this.player.body.touching.down && this.isJumping) { //if up in the air //console.log('player is in the air'); //this.player.x = 400; this.canShoot = true; } if (this.isShooting && this.player.body.touching.down) { //if shooting this.isShooting = false; this.player.body.velocity.x = this.levelSpeed; } /* CONTROLS */ if(this.cursors.up.isDown || this.game.input.activePointer.isDown){ this.playerJump(); } else if (this.cursors.up.isUp || this.game.input.activePointer.isUp) { this.isJumping = false; } if(this.spaceKey.isDown){ this.shoot(); } /* PLATFORM CREATION */ //if the last sprite in the platform group is showing, then create a new platform //console.log(this.currentPlatform.children); if(this.currentPlatform.length && this.currentPlatform.children[this.currentPlatform.length - 1].right < this.game.world.width) { this.createPlatform(); } /* KILL SWITCH */ //kill coins that leave the screen this.coinsPool.forEachAlive(function(coin){ if (coin.right <= 0){ coin.kill(); } }, this); //kill enemies that leave the screen this.enemiesPool.forEachAlive(function(enemy){ if (enemy.right <= 0 || enemy.left <= 200){ enemy.kill(); } }, this); } /* ALLOW ENEMIES TO REMAIN ON PLATFORMS AFTER DEATH */ this.platformPool.forEachAlive(function(platform, index){ this.enemiesPool.forEachAlive(function(enemy, index){ this.game.physics.arcade.collide(enemy, platform); }, this); }, this); /* CHECK IF PLAYER NEEDS TO DIE */ if(this.player.top >= this.game.world.height || this.player.left <= 0 || this.myLivesLeft <= 0) { //alpha doesn't work when bitmapData sprite is continuously redrawn //so only run gameOver once this.player.play('dying'); this.playerLives.destroy(true, true); this.speedUpTimer.destroy(); this.nextLevelTimer.timer.destroy(); if(this.gameOverCounter <= 0) { this.gameOver(); this.gameOverCounter++; } } }, Any suggestions would be appreciated!