anthkris Posted January 23, 2017 Share Posted January 23, 2017 Howdy all, I've looked everywhere but I can't seem to find an answer. I'm making an infinite scroller. The platforms are automatically generated and they are made up of a pool of floor sprites nested into a pool of platforms (groups of floor sprites). For example: // Creating platforms in Game.js createPlatform: function(){ var nextPlatformData = this.generateRandomPlatform(); if (nextPlatformData) { this.currentPlatform = this.platformPool.getFirstDead(); if (!this.currentPlatform) { this.currentPlatform = new SupRun.Platform( this.game, this.floorPool, nextPlatformData.numTiles,this.game.world.width + nextPlatformData.separation, nextPlatformData.y, -this.levelSpeed, this.coinsPool, this.enemiesPool, this.enemySprite, this.player, false); } else { this.currentPlatform.prepare( nextPlatformData.numTiles, this.game.world.width + nextPlatformData.separation, nextPlatformData.y, -this.levelSpeed, this.coinsPool, this.enemiesPool, this.enemySprite, this.player, false); } this.platformPool.add(this.currentPlatform); this.currIndex++; } } //Creating groups of floor sprites in Platform.js prefab SupRun.Platform.prototype.prepare = function(numTiles, x, y, speed, player) { //console.log(speed); this.alive = true; var i = 0; while(i < numTiles){ var floorTile = this.floorPool.getFirstExists(false); if (!floorTile){ floorTile = new Phaser.Sprite(this.game, x + i * this.tileSize, y, 'floor'); } else { floorTile.reset(x + i * this.tileSize, y); } this.add(floorTile); i++; } //set physics properties this.setAll('body.immovable', true); this.setAll('body.allowGravity', false); this.setAll('body.velocity.x', speed); this.addCoins(speed); this.addEnemies(speed, this.player); }; The player collides with the top of the of the platforms just fine. However, I would like the player to hit the side of the wall and just fall straight down, instead of falling through. Is this possible? Link to comment Share on other sites More sharing options...
anthkris Posted January 25, 2017 Author Share Posted January 25, 2017 I finally figured this out thanks to this thread: I was manipulating player.x, which was fiddling with collision. Now I just need to fix an issue where the player's position keeps getting screwed up when hitting an enemy. Link to comment Share on other sites More sharing options...
Recommended Posts