• Content Count

  • Joined

  • Last visited

About Alamantus

  • Rank

Recent Profile Visitors

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

  1. If the same bullet is not going to be re-used again later, it should be removed from the game using destroy() instead of kill(). This will remove the bullet from the game, which would definitely stop the updating. To answer your question directly, though, in your update function, you can check the bullet's sprite for its alive property before running its update. All kill() does is set a few booleans to false so the sprite will stop displaying, not remove anything: Sprite.kill() docs
  2. Hi Claudiovc, thanks for that quote! That does make sense, but it's a little bit unfortunate for me because I was hoping to separate out my code a little bit more and save on some processing time—I wanted to have the main map screen be one state that generates hundreds of items and then have the Inventory and various events to be other states that can move back to the map without regenerating to save a little bit of processing power/loading time. But if the best way to do it is to just regenerate, then that totally makes sense to me. I'll just throw up the loading icon more often.
  3. I don't think there is a game.scale.onResize function that you can set (at least, I don't see it in the current Phaser version's documentation anywhere), but there is a game.scale.onSizeChange Signal that you should be able to use like this: game.scale.onSizeChange.add(this.onResize); // Or maybe this, actually. I'm not sure which off the top of my head: game.scale.onSizeChange.add(function () { this.onResize(); }, this); Or maybe even using the game.scale.setResizeCallback() method, since that's what the documentation's game.scale.scaleMode entry mentions: game.scale.setResizeCallback(function () { this.onResize(); }, this); Maybe these would work better?
  4. Here's my situation: When the main game state starts, it generates a couple hundred objects (sprites, images, etc) scattered around the world, but when I change to a different state, the objects are removed as normal, and when I change states back to the main state, the objects are re-generated. I'm trying to figure out a way to not re-generate that large number of already-generated objects when I switch back to the main state. I already know that game.state.start() gives you the option to not clear the world, but this keeps the objects from the previous state displayed. Is there a way to store those objects so they don't appear when the state changes and then reappear on the screen where they were when the state is set back to the first state? More details: I'm making an AR mobile game that uses random seeds based on the current geolocation and time (rounded to minutes) to generate objects with limited lifetimes. I'm trying to make it so that objects that are close to being destroyed still appear even though re-generating the objects would not generate them. For example, an object was generated 5 minutes ago and will die in 2 minutes. The state changes and the player does stuff in that state then goes back. The object still should have 1 minute left before it disappears but it is already gone because time has moved forward to the point where it would not generate the object again. I'd like that object to remain and live out that last minute of its life since it was there before the player changed states and should be there when they get back.