• Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    Bonsaiheldin reacted to rich in Make sprites / images ignore camera zoom   
    There's no way to stop a Game Object responding to a Camera's zoom or rotation because the display list works by taking the transform matrix for the camera and then applying it down the whole list. It can't selectively only take part of it for just some of the children.
    The easiest solution I think would be to have a parallel Scene on the top of the game scene, which holds just your name tags, and position them relative to the sprites in the Scene below. Alternatively, you could use a second Camera that ignores everything other than name tags, and have the main Scene camera ignore all name tags. Then zooming the main camera won't impact the tags, because the 'tag' camera can stay as-is.
  2. Like
    Bonsaiheldin reacted to samme in Arcade physics friction??   
    In Arcade Physics friction is how much (in range [0, 0] to [1, 1]) of a platform's velocity is transferred to an object riding it.
    You can use drag on the player to slow it down.
  3. Like
    Bonsaiheldin reacted to samme in [SOLVED] Preventing child sprites from changing their position with their parents rotation?   
    It's because preRender is quite late, and the transformation for the current frame has already been calculated.
    Probably states need a postUpdate method for these things.
    There's also 
  4. Thanks
    Bonsaiheldin reacted to samme in [SOLVED] Preventing child sprites from changing their position with their parents rotation?   
    I think you need 
    this.tanks.updateTransform(); at the end of preRender().
  5. Like
    Bonsaiheldin reacted to samme in [SOLVED] Preventing child sprites from changing their position with their parents rotation?   
    See the preRender method in
  6. Confused
    Bonsaiheldin reacted to jonforum in I completed my first Phaser Game, I would like to put it up on the Google Play store.   
    i use intel xdk,   has been discontinued.
    But it also existe some old setup shared on the web.
  7. Thanks
    Bonsaiheldin reacted to samme in [SOLVED] Preventing child sprites from changing their position with their parents rotation?   
    You can use transformCallback but I think that's even more complicated.
    I would either use a Group or else no containers at all (and update the healthbar's position manually).
  8. Like
    Bonsaiheldin reacted to EpicKingdom_ in Where to get game assets?
  9. Thanks
    Bonsaiheldin reacted to i.wnek in Fading out emitters particles   
    I'm trying to do simple explosion with emitter. I want particles to slowly fade out so I do:
    emitter.setAlpha(0.2, 1, 10, Phaser.Easing.Linear.None, false); emitter.autoAlpha = true; But when i run game and emitter start doing it's job it throws at the console:
    Uncaught TypeError: Cannot read property 'v' of undefined at Phaser.Particle.update (phaser_phaser_1.js:99052) at Phaser.Particles.Arcade.Emitter.update (phaser_phaser_1.js:99548) at Phaser.World.Phaser.Group.update (phaser_phaser_1.js:33716) at Phaser.Stage.update (phaser_phaser_1.js:31820) at Phaser.Game.updateLogic (phaser_phaser_1.js:36338) at Phaser.Game.update (phaser_phaser_1.js:36280) at Phaser.RequestAnimationFrame.updateRAF (phaser_phaser_1.js:61979) at _onLoop (phaser_phaser_1.js:61962)  
    What am I doing wrong with this task?
    Solved - it seems like I set too low alpha rate parameter (third param. in setAlpha).
    I misunderstood how it works. Now I get it. If I set rate as 1500 ms particles will fade out in this time. It works now.
  10. Confused
    Bonsaiheldin reacted to b10b in How do turrets in games fire in salves / volleys (not at the same time)?   
    Modulo Operations can be useful for offsets like this.  It might work that each turret has its own "seed" (e.g. 1...12) .  Then, each game-loop tick, increment an "updates" counter.  Then lastly only consider firing if "updates%12=seed".  Using unique prime numbers for the seeds can help make any emergent patterns more varied, or use consecutive seeds for quick succession.
  11. Like
    Bonsaiheldin reacted to vamos in Let the browser download the game's assets as a one archive file?   
    You can do that, I've used JSZip to do this same thing. No need for the File API as such, you can extract data from the zip as blobs or Uint8 arrays or whatever suits your needs.
    To be honest it does speed things up a bit, but there may be better ways. For example if you use HTTPS then the client can do batched requests, and that's a big speed up.
    The big disadvantage of the zip approach is that you can't cache individual files - if you need to change one asset, you need to change (and the client needs to re-download) the whole zip.
  12. Like
    Bonsaiheldin got a reaction from zelcard in [Phaser] Copter Rescue   
    Nice little game. Reminds me of Flappy Bird and similar. 🙂 I like the pixel graphics.
    One suggestion: It seems the game doesn't save the progress. It would be nice if it did. I don't know how this behaves on mobiles, i'm using a desktop browser.
  13. Like
    Bonsaiheldin reacted to Straker in How to handle collision between sprite and tilemap?   
    What is commonly done is that a 2nd tilemap is created whose sole purpose is to deal with collisions. This collision tilemap just holds information about where collisions will occur and what type of tile the collision is. Then when you move the player, you just check where the player is going against the collision tilemap and if the tile the player is moving into has a tile, you can check what type of tile and respond accordingly.
    So for example, let's say you have a room surrounded by walls (represented by tile #1) with a river of lava through it (represented by tile #2) and any tile that doesn't have a collision will be empty (represented by tile #0). The collision tilemap could look like the following:
    collisionTilemap = [
       [1, 1, 1, 1, 2, 1, 1, 1, 1],
       [1, 0, 0, 0, 2, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 0, 0, 1],
       [1, 0, 0, 0, 2, 0, 0, 0, 1],
       [1, 1, 1, 1, 2, 1, 1, 1, 1]
    When the player tries to move into a tile with the #1, he is just prevented from moving into the square. But if the player tries to move into a tile with the #2, the player dies because he touched lava.
  14. Like
    Bonsaiheldin reacted to anthkris in How to handle collision between sprite and tilemap?   
    In that example, collision had not been set previously on that tile. If you change the map collision statement thusly:
    map.setCollisionBetween(1, 26); Then, you will collide with the coin, the alpha will change, but you will not pass through.
  15. Like
    Bonsaiheldin reacted to anthkris in How to handle collision between sprite and tilemap?   
    Wanted to make sure I posted this @symof. I submitted an issue and got some answers. You need to return true in the callback function to keep the tile impassable.
  16. Like
    Bonsaiheldin reacted to rich in Checking if mouse is over a sprite (hover)?   
    This is how you set-up Button callbacks:
    Look at the code for this example, you'll also see that it works on the site (using 2.5.0), i.e. the button changes frame on mouse over, without any click needed.
  17. Like
    Bonsaiheldin reacted to lewster32 in Apply force to sprite   
    An explosion can be thought of as a single frame velocity change on all objects in a radius of the epicentre, with the amount of change determined by the distance from the epicentre and the mass of the object. If you're using gravity and drag, the objects will react relatively realistically, and not go flying away from the explosion forever. Here's how I see an explosive force working:
    Grab all of the objects in a predetermined radius of the explosion by looping over your game objects and using Circle.contains to see if their position lies within the circle. You could maybe make use of an overlap test with a square body of the same size as the circle to make use of the QuadTree optimisation if you have lots of objects in your world. For each object, check the distance and the angle (in radians) from the explosion's centre point. Using the angle and the inverse of the distance, perform some simple trigonometry to determine which direction and with what force you need to add to an object (optionally taking into account mass): var force = (radius - distance) / mass; object.body.velocity.x += Math.cos(angle) * force; object.body.velocity.y += Math.sin(angle) * force; By adding the forces rather than setting them, you alter the existing motion of objects rather than just overriding it. This means objects moving into an explosion will be less affected than objects moving away, which is desirable if realism is your thing.
    The above calculations are pretty simplified in the grand scheme of things, but they should provide a pretty nice effect nonetheless. To increase the force of the explosion, you just need to increase the radius and things should react accordingly; objects at the same distance from a larger explosion will have more force applied to them. You can of course add a separate 'force' value into the explosion and the calculation which I guess could act as a multiplier, so you could make small but powerful blasts. I'll leave that to you to add if you wish!