• Content Count

  • Joined

  • Last visited

About Cudabear

  • Rank
    Advanced Member

Recent Profile Visitors

1507 profile views
  1. Hi all, Just wanted to share a workaround I made today while trying to increase the performance of tilemaps in my game. My game has maps that could be 2048px X 2048px (64x64 32px X 32px tiles) or maybe even bigger down the road, and contain up to 8 layers for applying detail. The problem I ran into was, when scrolling the camera, I was seeing huge performance drops, even on powerful computers. Turns out, Phaser was redrawing the tilemap every frame you move the camera. My tilemap, after being loaded, never really changes. So I wanted to find an easy way to force Phaser to draw the entire tilemap once and then use it for a static sprite after that. I tried using, but it didn't seem to work. Not sure if I was missing something there. So my solution was to resize the layer before getting the texture: myLayer.resize(,; myLayerTexture = myLayer.generateTexture(1, PIXI.scaleModes.DEFAULT, game.renderer); myLayer.visible = false; game.add.sprite(0, 0, myLayerTexture); this way, instead of the tilemap being added as a dynamic thing that gets redrawn constantly, it functions as a static image. But because each layer is still treated as a separate image, I preserve rendering order. In the background, I keep the actual layers hidden to preserve collision data. Unfortunately, if the tilemap were to change ever beyond initial creation, the texture would need to be updated, which would be expensive. But since I'm not really planning on doing that, it seemed like a reasonable solution to me. Hope this helps someone else who has this problem.
  2. Hard to tell without seeing the rest of code. What you've posted seems like it should be working. Have you enabled arcade physics on PlayerHitbox, Player, and Enemy1BGroup?
  3. Looks like you'll be on your own for this one. You could build it using some logic and well-positioned sprites, but that would take a lot of work. Since you have full access to the DOM anyway, you may just want to float a select over your canvas at the correct position, and then use CSS to style it as close as possible to match your game. It should save you a lot of time in the long run.
  4. So your line: diamond.reset(350, 350) sets the diamonds to spawn at that exact position in the world each time you make a new one (x350, y350) You can use and to get a random position in the world to spawn them in. as such: diamond.reset(, This may spawn the diamond inside the tilemap, so you may want to work around that somehow.
  5. For the first one, you're calling it every time through the update loop. You can use justPressed to prevent this if(controls.attack.isDown){ player.body.velocity.x = 0; if(controls.attack.justPressed) { //only play the animation if the user just pressed the key'attack', 7, false); } } For the second one, your idle animation is getting played every time your player sprite doesn't have x velocity. Since the jump is called whenever the user is jumping, I'd do something like this: if(!controls.attack.isDown){ if(player.body.touching.down){ //if we're on the ground, handle ground animations if(player.body.velocity.x === 0){'idle'); } else { //walking animations???? } } else { //if we're in the air, we're obviously jumping or whatever'jumping'); } }
  6. You can pass a group as the arcade physics overlap function. That said, you need arcade physics on all sprites within the group as well as the sprite you want to check against the group. If you feel you don't need physics on the group's sprites, check this example: Also, for future reference, you can forEach any group do custom work on each of its elements independently, just like a vanilla javascript array.
  7. I don't believe Phaser does anything other than importing the tileset image. It might be a browser specific issue with the way you exported your tileset. I'd play around with different browsers and image file formats to see if you can fix it. That said, I've never seen this issue with png tileset images in chrome.
  8. You could probably set the character sprite to be a child of the ball, with the appropriate offset of the default state (let's say moving to the left). Then, when the player moves to the other state (the right) flip the x scale of the character sprite, from 1 to -1. The character should now be facing the opposite direction on the other side of the ball.
  9. I'm pretty sure body.touching never cares to check to see what it's touching. In order to do this, you'll probably want to add all the sprites that you want to affect by touching to a group, then call game.physics.arcade.collide(sprite, group, function(sprite, collidedSpriteFromGroup) { //affect collidedSpriteFromGroup here }); inside your update loop. This example uses overlap instead of collide, but it's effectively the same thing:
  10. Tip: use non-minified Phaser for dev to get more descriptive errors. Looks like your animations are failing to play. Have a look at player.animations.add('left', [0, 1, 2, 3], 10, true); player.animations.add('right', [5, 6, 7, 8], 10, true); And see if those indexes are configured correctly (you have enough frames in the image, and so forth.
  11. As far as I know, this isn't really feasible because there's no way to know how big the file being downloaded is. It's possible to get the `header` information from the request to get the total number of bytes downloaded already, and then compare that to some hard-coded value about the size of the value (or fetch the size of the file via some back-end request) but that seems fragile and too heavy-handed. Most Phaser games show progress as a percent of total files downloaded (not great if you've got a big sprite atlas, or large music files, but it's something at least) Here's my example of how I show progress of loaded files: The important line is `this.load.setPreloadSprite`.
  12. I linked the github in the post. It was made for a gamejam so it's all open source. Feel free to take, use, and refactor anything.
  13. It lists an example under the documentation here.
  14. Cudabear

    Ludum Dare

    Awesome! Good work on your game too It would be a shame for you not to post it just because you missed the Compo deadline!