damager

Members
  • Content count

    8
  • Joined

  • Last visited

  1. Sprite pool reusing bug(?)

    20 hours fighting with this "bug"...but fixed. Problem was in this line this.bullet = this.bullets.getFirstExists(false); That is correct version: this.bullet = this.bullets.getFirstExists(false, false, this.player.x -14+(28*i), this.player.y - this.player.height/2); i don't know why, but if i don't set position in this method, and set it up later this "bug" shows up.
  2. Sprite pool reusing bug(?)

    That's not object pool bug, i've found that bug appears when i use bullet.kill() right at the moment when collision is started (OR i'm wrong, cause hard to recreate bug when i slowly move the ship that fires bullets). But i don't know how to fix this and why it appears in that way...Can i somehow clear colliding forces when i use bullet.kill() function? Does someone know? (Plz help, my brain is literally blowing up) Thanks)
  3. Sprite pool reusing bug(?)

    Hi, i'm going to create phaser runner game, but i stuck with one problem. I create a bullets like this: this.bullets = this.game.add.group(); this.bullets.name = 'bullets'; this.bullets.enableBody = true; this.bullets.physicsBodyType = Phaser.Physics.P2JS; this.bullets.createMultiple(100, 'playerBullet', 0, false); this.bullets.forEach(function(child){ child.body.setRectangle(25, 35, 0, 0); child.name = "bullet"; child.anchor.set(0.5, 0.5); child.body.motionState = Phaser.Physics.P2.Body.KINEMATIC; //child.body.debug = true; child.body.onBeginContact.add(SimpleGame.prototype.onBulletBeginContact, this); }, this); this.bullets.setAll('outOfBoundsKill', true); this.bullets.setAll('checkWorldBounds', true); and creating them 5 times at second this.shotTime.loop(200, SimpleGame.prototype.shotTheEnemies, this); shotTheEnemies(e:Phaser.TimerEvent) { let bullet: Phaser.Sprite; for (var i = 0; i < 2; i++) { bullet = this.bullets.getFirstExists(false); if (bullet) { bullet.reset(this.player.x -14+(28*i), this.player.y - this.player.height/2-20); bullet.body.moveUp(900); //console.log(bullet.body.) } } } But in time when bullets hit enemy and i use bullet.kill() some of pool bullets don't have speed(And i can't manipulate them till i use bullet.kill again, BUT i don't know which bullets are lag). That's not happening when bullets hit the world bounce. Please help)
  4. Phaser poor performance on mobile

    debug.text is really slow method. How many fps without whis method? On my mobile game with this method runs 45-55 fps(Meizu m3) also you should use bitmap texts, they improve performance but require a lot of memory
  5. Phaser resizeChange

    Thank you for the answer, but my problem was pretty easier than i thought. i've just changed the path to function. Somehow it didn't see it; this.game.scale.setResizeCallback(this.resizeCallBack, this); That's work: this.game.scale.setResizeCallback(SimpleGame.prototype.resizeCallBack, this);
  6. Phaser resizeChange

    i found solution, but it can be not right one.. i've removed setResizeCallback and replaced onSizeChanged to time.event.loop with checking the changing of window size...But i still hope there is an event(Signal) to detect changing window size.
  7. Phaser resizeChange

    Hi(sorry for my English), i've just started using Phaser, but i stucked with one problem. I have a problem with resizeChange of my game. onSizeChange and setResizeCallback just don't work. When i resizing my browser they don't generate signals. I know there is many themes like that but i've seen every of them and didn't find a solution. Please help) P.S: Phaser 2.9.1. May be trouble in this version of Phaser? In that version even state.callbackContext.resize() was removed. My typescript code(code for resizeCallback i've took from another theme): this.game.scale.setResizeCallback(this.resizeCallback, this); this.game.scale.onSizeChange.add(()=> { let scale_x: number = window.innerWidth / this.game.width; let scale_y: number = window.innerHeight / this.game.height; this.game.scale.setUserScale(scale_y, scale_y); this.game.scale.align(true,true); this.game.scale.scaleMode = Phaser.ScaleManager.USER_SCALE; this.game.scale.refresh(); alert("huh"); }, this) resizeCallback(manager) { var userRatio = 1; if(this.game.device.pixelRatio>1) { userRatio = this.game.device.pixelRatio * 1; } if(manager.width !== window.innerWidth*userRatio || manager.height !== window.innerHeight*userRatio) { manager.setGameSize(window.innerWidth*userRatio,window.innerHeight*userRatio); manager.setUserScale(1/userRatio, 1/userRatio); } }