• Content Count

  • Joined

  • Last visited

1 Follower

About MeMyMo

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. So it was actually working, it was just that I had a black background and the camera followed my character. Doh.
  2. I haven't been able to figure this out. I have a "Player" class that extends Sprite: export default class Player extends Phaser.GameObjects.Sprite{ constructor(scene, x, y, config) { super(scene, x, y, config.key); this.scene = scene; this.lastAnim = null; this.vel = 200;; this.scene.add.existing(this); const { LEFT, RIGHT, UP, DOWN } = Phaser.Input.Keyboard.KeyCodes; this.keys = this.scene.input.keyboard.addKeys({ left: LEFT, right: RIGHT, up: UP, down: DOWN, }); } preUpdate (time, delta) { super.preUpdate(time, delta); const keys = this.keys; let animationName = 'player-idle'; if (keys.left.isDown) { this.body.setVelocityX(-this.vel); this.setFlipX(true); } else if (keys.right.isDown) { this.body.setVelocityX(this.vel); this.setFlipX(false); } if (keys.up.isDown) { this.body.setVelocityY(-this.vel); } else if (keys.down.isDown) { this.body.setVelocityY(this.vel); } // TODO: Clean this up if (keys.up.isDown || keys.down.isDown || keys.left.isDown || keys.right.isDown) { animationName = "player-walk"; } else { animationName = 'player-idle'; } if(this.lastAnim !== animationName) { this.lastAnim = animationName;, true); } } } I instantiate it in the "create" method of the scene: this.player = new Player(this, 300, 300, {key: 'player'}); The Sprite animates and everything, but it just stays in the same place. My game setup: const gameConfig = { width: 1024, height: 768, scene: GameScene, pixelArt: true, zoom: 2, physics: { default: 'arcade', arcade: { gravity: { y: 0 }, debug: false } }, }; I've seen examples that create an update method then call it in the scene update loop, but shouldn't preUpdate be the same? Any help appreciated!
  3. It seems to work for me in VS Code?
  4. I don't know if this helps, but someone ported Box2D to JS recently: Maybe the performance is better?
  5. Basically what the title says. I'm having a hard time thinking how you can build a simple UI with some dynamic text/buttons/scrollable fields, etc. A group with sprites? Outside of Phaser with HTML/CSS?
  6. I'm an idiot, the walkable tile was 3, not 2.
  7. Hey, I'm messing around with pathfinding. Modified the Easystar Phaser plugin for ES6, but it seems to always return an empty path: (source is 0,0) Calculation is here: ... let walkableTiles = [2, 150, 152, 166, 35, 68, 18] this.pathfinder =; this.pathfinder.setGrid(this.layers[1].data, walkableTiles); } update () {} findPathTo(fromX, fromY, toX, toY) { this.pathfinder.setCallbackFunction((path) => { path = path || []; console.log(`path: ${path}`); // for(var i = 0, ilen = path.length; i < ilen; i++) { // map.putTile(46, path[i].x, path[i].y); // } }); console.log(this.layers[1].data); console.log(toX); console.log(toY); this.pathfinder.preparePathCalculation([0, 0], [toX, toY]); this.pathfinder.calculatePath(); } Grid data looks good... ideas?
  8. You would need to use something like this:
  9. You could do something like: var tile; var map = []; var tileWidth = 38; for (var xx = 0; xx < 10; xx++) { map[xx] = []; for (var yy = 0; yy < 10; yy++) { // Create a tile using the new game.add.isoSprite factory method at the specified position. // The last parameter is the group you want to add it to (just like game.add.sprite) tile = game.add.isoSprite(xx tileWidth, yy * tileWidth, 0, 'tile', 0, tileGroup); tile.anchor.set(0.5, 0); map[xx][yy] = 1; } } console.log(map) But you should probably look into tilemaps and Tiled, it'll help a lot. Also, there's a Phaser plugin to help out with pathfinding:
  10. I've been looking at how BrowserQuest does it and I'm getting a better idea. I'll read up on your link Skeptron, too. For the moment I'll go with something a bit more amateur-ish, I don't think it's all that important that it's 'hackable' as much as releasing something is. Appreciate the input guys, thanks.
  11. Maybe something simpler, like: if (direction != 0) { //Move this.player.body.velocity.y = direction * this.PLAYER_SPEED; } if (firePress) { //Fire this.createPlayerBullet(); }
  12. Might have better luck here:
  13. Ah, sorry about that. Googled a bit and it looks like it's not as straightforward. Maybe: ?
  14. Hey, So I'm messing around with Phaser and Socket.IO, I got a simple "game" working where multiple players can connect and you can see each other/move. The thing is that movement/collisions (for the current player) is client side, relying on arcade physics and x/y velocities. I'm a webdev, so I know it's not smart to rely on the client, but I'm having some difficulty understanding how I would do collisions/movement on the server side. Movement might be easier, I could probably have an update loop on the server and just send over the player's moving direction and then calculate the new coords on the server and send them back, but that would defeat the purpose of using collisions on the client, no? Am I right thinking that I will have to run my own collision logic in the server? Any pointers on what I should do? My "game": (Yeah, sometimes it doesn't spawn where it should...) My repo: Any help appreciated!
  15. I would start with free resoures, Phaser has some: