hexus

Members
  • Content Count

    62
  • Joined

  • Last visited

Everything posted by hexus

  1. Yeah, that seems to be the case. I've tried to do this before, I think (or something similar) and realised that the actual JSON was discarded by the loader. As such, I just provided the data I needed separately and I explicitly load it as a JSON file so I can retrieve it from the cache later. This is what I'd suggest for you, @geros. Load your extra data for the atlas separately and match it up once everything has loaded. Edit: Sorry for the necro, I misread the dates. This was brought up in the Phaser Slack.
  2. v0.3.0 is now a thing, with less features than intended because I just wanted to get the new collision handling out there. It now makes smarter use of the SAT algorithm to avoid unwanted collisions. The old, flaky heuristics are a thing of the past. It should also be less memory hungry. No more calls to .clone() on SAT response objects or vectors. They're all pooled now, with use of .copy() instead. In my own game development, I also found issues with the consistency of the response objects when unwanted collisions were ignored. This should now no longer be an issue. I discovered this when I used the collision vectors to rotate a player sprite (a feature that will be built in to the plugin at some point).
  3. Thanks! Yeah, actually, quite a good idea so far. I'll be removing the heuristics in place of smarter use of the SAT algorithm (this has already been done) Memory consumption improvements (mostly already done) There will be solutions implemented to help avoid tunnelling (such as swept intersection tests) There may be a built in raycaster for line intersection tests against tilemaps Auto-rotation for sprites based on collision vectors, optionally restricted to a range of angles For more, you can check out the roadmap. Whenever I get an idea for something that I'm pretty confident I want to implement, I put it there. For v1.0.0 I plan to build large polygons from the the tiles, as well as support actual polygons from Tiled maps as collision shapes/objects. There's a plugin that already does this by @michaelcalkins, called Arcade Polygons, which is in fact based on some of my code for the plugin and initial SAT proof of concept, but I've planned to do something like that from the beginning.
  4. If it was an event, Phaser would have to test all game objects for all possible collisions all the time. Instead, when you call overlap, you're causing the physics engine to check for overlaps, and if it returns positively your callback is invoked.
  5. Resize the layer separately, keep the world far bigger than your map, and you're all good. See Phaser.TilemapLayer.resize(). The layer's "size" here is actually the size of the sprite it's being rendered to, like a TileSprite. So jpdev is spot on indeed, the layer is not the right size.
  6. Thought I might as well update this thread with the changes between v0.2.0-beta and v0.2.0. v0.3.0 is now in the works!
  7. Didn't know you could do that with tilde operator! Neat.
  8. I've been having problems trying to implement this myself, and Phaser 2 really isn't cut out for it. While your implementation would work, @feudalwars, it also means rendering the scene at a different resolution. This isn't zoom the way it should work, unfortunately. As a consumer of an API, I'd expect game.camera.scale to handle this correctly. Instead, all sorts of things break. Specifically tilemap layer rendering and collisions, and world bounds collisions.
  9. preRender() might help you there.
  10. I'd suggest using a single, invisible collision layer (doesn't even need to be rendered), then layering your visible artwork separately. Then, use a foreground layer for tiles that the character has to be behind, such as the roof of the building, and a background layer for everything else. This way, your collision information is separated from your artwork, giving you a little more freedom at the expense of another layer of data. Just my suggestion though.
  11. It's one way of many for you to distribute your code. I use npm to include Phaser in my projects, you can also use package managers like Bower. Take your pick, but I assume npm is easily the most widely used.
  12. Hello everyone! I've recently released v0.2.0-beta for you all to check out. It comes with several new features: Premade tilesets Built in tileset slope mappings for Ninja Physics and Arcade Slopes tilesets Debug rendering for tile polygons (tilemapLayer.debug = true) Offset tilemap layer support (though this has always been janky in Phaser) Circular physics body support Tile collision flag support Grab a copy here. Check out the demo! The demo has been updated with Phaser CE 2.7.3 and Arcade Slopes v0.2.0-beta. It lets you change the player's shape & size and witness the debug rendering.
  13. Feel free to share how you solved the problem, in case anyone else wants to know the same thing.
  14. The plugin shouldn't be constrained to tiles of any specific size, it will use whatever width and height each tile has set, which will come from your map data.
  15. If you only need rectangular physics bodies to collide with slopes on a single, non-offset tilemap, then yes. However, consult the roadmap for features I'm intending to implement. While circular physics bodies have been implemented, there is still a really strange issue where it teleports the body after catching between square tiles. Not being able to solve this problem put me off working on the plugin for a while.
  16. Slightly questionable using world.player like that, it doesn't take into account the asynchronous nature of Node. It'd be safer just to use an object pool.
  17. this.game.slopes.convertTilemapLayer is the converter, perhaps that's not clear enough in the readme. You just map the index of each tile to one of the available tile shape types. I don't have a handy wiki for people to look up these constants with their corresponding shapes though. I would suggest using a Tiled map instead, and using an invisible collision layer that uses the ninja physics tilesheet and mapping. Then your graphical tiles aren't tied to the collision tiles.
  18. Which makes sense. How do you scale 1.32546 of a pixel without anti-aliasing?
  19. Yeah, as Lewster said, the largest the device can support will be the best. Less to send to the GPU and potentially less draw calls needed. http://www.adriancourreges.com/blog/2016/09/09/doom-2016-graphics-study/ I've always found articles like this enlightening. For Doom, they throw everything into these mega textures! iD have done it that way for ages, apparently.
  20. Here's your fixed game state. There were a number of bugs to begin with, particularly the fact that your CSV tilemap doesn't have layers, so you just need to pass 0 instead of 'collision'. Also, because your tilesheet doesn't have the same layout as the Ninja Physics debug tilesheet, the mappings of course wouldn't work, so I estimated a mapping for your current tilesheet. The JavaScript should be all you need to change. Happy coding! /** * Created by Welcome on 03/10/2016. */ var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); function preload() { this.game.load.tilemap('tilemap', 'assets/tilemaps/csv/tiles.csv', null, Phaser.Tilemap.CSV); this.game.load.spritesheet('tiles', 'assets/tilemaps/tiles/snow_tiles_32.png', 32,32); this.game.load.spritesheet('player', 'assets/penguin.png', 32,48); } var cursors; //var snowballs; //var sTime = 0; //var fireButton; function create() { this.game.physics.startSystem(Phaser.Physics.ARCADE); this.game.plugins.add(Phaser.Plugin.ArcadeSlopes); cursors = game.input.keyboard.createCursorKeys(); this.map = this.game.add.tilemap('tilemap'); this.map.addTilesetImage('snow_tiles_32', 'tiles'); this.game.stage.backgroundColor = '#80e3ff'; this.ground = this.map.createLayer(0); this.ground.resizeWorld(); this.game.slopes.convertTilemapLayer(this.ground,{ 1: 'FULL', 2: 'FULL', 3: 'FULL', 4: 'FULL', 5: 'FULL', 6: 'FULL', 7: 'FULL', 8: 'FULL', 9: 'HALF_TOP', 10: 'FULL', 12: 'FULL', 13: 'HALF_BOTTOM_LEFT', 14: 'HALF_BOTTOM_RIGHT', }); this.map.setCollisionBetween(1, 34, true, 0); //player this.player = this.game.add.sprite(100, 50, 'player'); this.game.physics.arcade.enable(this.player); this.player.body.slopes = {sat: {response: 0}}; // workaround for a phaser bug this.game.slopes.enable(this.player); this.player.body.slopes.preferY = true; // stops the player sliding down slopes this.player.body.bounce.y = 0.2; this.player.body.gravity.y = 2000; this.player.body.collideWorldBounds = true; this.player.animations.add('left', [0,1,2,3], 10, true); this.player.animations.add('right', [5,6,7,8], 10, true); //this.snowballs = game.add.group(); //this.snowballs.enableBody = true; //this.snowballs.physicsBodyType = Phaser.Physics.ARCADE; //this.snowballs.createMultiple(1, 'snowball'); //this.snowballs.setAll('anchor.x', 0.5); //this.snowballs.setAll('anchor.y', 1); //this.snowballs.setAll('outOfBoundsKill', true); //this.snowballs.setAll('checkWorldBounds', true); //this.fireButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); this.game.slopes.enable(this.player); this.game.camera.follow(this.player); } function update() { this.game.physics.arcade.collide(this.player, this.ground); this.player.body.velocity.x = 0; if(cursors.left.isDown){ this.player.body.velocity.x = -150; this.player.animations.play('left'); } else if (cursors.right.isDown){ this.player.body.velocity.x = 150; this.player.animations.play('right'); } else{ this.player.animations.stop(); this.player.frame = 4; } if(cursors.up.isDown && (this.player.body.onFloor() || this.player.body.touching.down)){ this.player.body.velocity.y = -350; } //if(fireButton.isDown){ //this.fireSnowball(); //} //} //function fireSnowball(){ //if(game.time.now > sTime){ //this.snowball = snowballs.getFirstExists(false); //if(snowball){ // this.snowball.reset(player.x+30, player.y+30); //this.snowball.body.velocity.x = 400; //this.sTime = game.time.now = 10; // } //} }
  21. Yes, it supports tiles of any size. I started building a tilesheet generator a while back, so that it'd be easy to grab an image that works with the plugin immediately, but I haven't put the time in to finish it yet.
  22. I agree that it could definitely be a more intuitive, but it didn't take me too long to work it out.