Jump to content

Search the Community

Showing results for tags 'phaser p2 physics sprite'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. ulixm

    Issue with P2

    Hello, I am developing a space shooter game with Phaser + P2 physics. During the game play, the player chooses one of the available weapons at a time to kill its enemies and, for all projectile based weapons, I have created a pool of shots. Everytime the player shoots a weapon, one of the "dead" projectiles is revived via Sprite.reset() method, then re-positioned, rotated and so on. Whenever a projectile hits a target or leaves the world it is killed via Sprite.kill() or Sprite.outOfBoundsKill flag and gets back to the pool. So far so good as it works almost 100% of the time. The problem is that sometimes (about 1 in every 100 shots), the projectile is revived but remains stuck on its new position until the game is restarted and the pool remains short of one projectile (or more if it happens more than once in the level). A debug analysis revealed me that although the projectile in this state doesn't interact with the world anymore (no collisions), it still exists (Sprite.exists === true), is alive, and has a physics body that is not sleeping. It seems however, that for some weird reason, it's body is not reinserted in the list of P2 bodies that should be updated by the main P2 loop. One possible but awful solution would be to monitor every revived projectile, for one frame, to detect the ones that are not moving. Then kill and revive those again. But that would be my last resort... Does anyone have any clue on why this is happening and how to fix it? This is the most relevant code: // Called when player fires a weapon reviveProjectile: function(group, xOfst, yOfst, ...) { var target = group.getFirstExists(false); if (target) { var playerShip = this.game.playerShip; playerShip.rotation = playerShip.body.rotation; this.tempPoint.setTo(xOfst, yOfst); var p = playerShip.toGlobal(this.tempPoint); target.reset(p.x, p.y); // Revive the projectile // ... }, // Called when the projectile hits something shotHit: function(shotBody, contactBody, baseDamage, ...) { if (contactBody.sprite) { shotBody.sprite.fireSoundFx.stop(); // Stop projectile launch sound shotBody.sprite.kill(); // Remove shot sprite // ... },
×
×
  • Create New...