• Content Count

  • Joined

  • Last visited

Everything posted by Bonsaiheldin

  1. Bonsaiheldin

    Make sprites / images ignore camera zoom

    Hello there. I have some images which have name tags on them, displaying names or quantities. The name tags are Text objects and i want them to stay of the same size independently of the camera's zoom. Something like that exists for camera scrolling: Sprite.setScrollFactor(0) makes sprites stay at the same position on the screen, no matter where the camera's position is or where it scrolls to. Is there something like that for zooming, too? I'm basically searching for a Sprite.setZoomFactor. At the moment i have my own camera zoom function which fires camera.setZoom and then iterates all name tags in the game and fires Text.setScale(1 / Camera.zoom). It works, but only as long as the zoom happens suddenly, not smooth. I've tried tweening the camera's zoom value and Camera.zoomTo. Both ways enable smooth zooming, but the name tags get distorted / pixelated when i use scaleX / scaleY tweens on them. Is there a possibility to make them just ignore the zoom or at least a zoomTo for sprites / images?
  2. Bonsaiheldin

    Make sprites / images ignore camera zoom

    Thanks rich. I'm going for the approach with the second camera, it's the most straight forward one to me because i haven't worked with scenes yet. It works. 👍 I now just have to calculate the image's positions on screen to properly position the name tags as they have to take the main camera's zoom into consideration. They are now only placed where they should be when the zoom is 1 of course. What's the formula to get an object's position on the canvas, taking zoom into consideration?
  3. Hello there. 🙂 I have a sprite which rotates. And i have a healthbar added to that sprite as a child. My problem is: The healthbar does what children are supposed to do! But i don't want that! 😅 How to keep child sprites from rotating with their parent? I want it to always stay at the same position relative to the parents anchor. I'm not talking about fixing its angle - that can be done by simply setting it to the negative angle of its parent each time it rotates (at least i don't know any other way). I'm talking about its position. Is there a fixedToCamera equivalent for sprites? If not, some math would be cool, too. EDIT: I guess this could work with groups. But is there another way?
  4. Yes, almost. I tried that without success and ended up using healthbar.updateTransform(); It seems you have to updateTransform the sprites, or group respectively, you want to change. That stuff is not really straight forward. I would never have thought about using such a function. 🤔 Thanks for your help! ✨ It now works as intended.
  5. Nice, i didn't know about that handy method! 🤓 Unfortunately, even though it works in your example, for some reason it doesn't change the behaviour at my game. I copy the necessary parts involved in movements. I don't know what is wrong here. I'm using Phaser-CE 2.10.3. Using position.copyFrom/To doesn't change it. update() { // Movement app.player.body.velocity.set(0); if (this.keyboard.isDown(Phaser.Keyboard.A) || this.keyboard.isDown(Phaser.Keyboard.LEFT)) { app.player.body.velocity.x =[].speed; } if (this.keyboard.isDown(Phaser.Keyboard.D) || this.keyboard.isDown(Phaser.Keyboard.RIGHT)) { app.player.body.velocity.x =[].speed; } if (this.keyboard.isDown(Phaser.Keyboard.W) || this.keyboard.isDown(Phaser.Keyboard.UP)) { app.player.body.velocity.y =[].speed; } if (this.keyboard.isDown(Phaser.Keyboard.S) || this.keyboard.isDown(Phaser.Keyboard.DOWN)) { app.player.body.velocity.y =[].speed; } // Collision this.physics.arcade.overlap(this.tanks, this.bullets, app.bulletHit, null, this); this.physics.arcade.overlap(this.tanks, this.expBubbles, app.expBubbleCollect, null, this); }, // The preRender method is called after all Game Objects have been updated, // but before any rendering takes place. preRender() { // Fix the tank's healthbar's position this.tanks.forEachAlive(function(tank) { let healthbar =; if (healthbar.visible) { healthbar.x = tank.x +; healthbar.y = tank.y +; //healthbar.position.copyFrom(tank); //healthbar.y +=; } }, this); }
  6. I see, thanks. For a quick fix i'm setting the healthbar's position manually for now, not having them as children of the players. It's not so beautiful as the healthbar's position using player.update is done some time after the player''s movement (using velocity), meaning one can see how it is always 1 - 2 frames behind. Gonna look into how a group would work here as i only have three groups yet, for the players, the bullets and the pickups.
  7. Bonsaiheldin

    Question about framerate.

    Sounds to me like your monitor just has a slow reaction time. Check the specs of it, it's measured in milliseconds. I'm not talking about the screen refresh rate which is measured in Hertz. My monitor does the same thing, because it has a slow reaction time of huge 10 ms or more. The same happens when i scroll on a website - text gets a bit blurry while i scroll and everything else gets trails. It's because it has no TN panel but an IPS one. They're slower but have much better colors, almost like OLED. If that's the case at you, then there's nothing you can do about it besides using another monitor. That would also mean, that you can't prevent that for other players if their screens have slow reaction times, too. At least i don't know how. Very fast screens have reaction times of 1 or 2 ms or less.
  8. This is a very general question about games where someone or something shoots bullets. I try to describe it the best i can. My picture might help, too. You know, there are games where you have ships with their turrets firing their bullets or lasers or whatever. But the turrets don't fire at the exact same time, even if they're all ready and have the exact same reload speed. They fire with a short delay in between, making the bullets form cascades or salves / volleys. The delay also is not just a random number but predictable. This allows for continous shooting without pause. An example of a game where this happens is Space Pirates and Zombies (the missiles). Does somebody know the mechanic behind this? I guess it's pretty trivial once you got it. 🤔 My own theory is that when the fire event happens, a shot fires and then the next turret has a slightly higher shootNext timestamp. But i can't get my head around how to code that. 😣 EDIT: What works a bit, is the following piece of code (using Phaser 2, Javascript). Though it makes my turrets just switch between shooting in volleys and altogether. 😰
  9. Hello there. Reducing the number of files downloaded is important for faster loading browser games because often the number of parallel connections is limited to 2, 4 or 8. So, i was wondering if it could actually work to load all the assets as an archive, extract it afterwards and then let the game grab and assign them. Has anyone experimented with that? Maybe with some magic of the File APIs, somehow? Does that actually work? Regards
  10. Bonsaiheldin

    [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.
  11. Bonsaiheldin

    Checking if mouse is over a sprite (hover)?

    Thanks for the link, rich. For some reason i don't understand it suddenly works now. I haven't changed a single character of my whole game code - it just works since your comment here. It has not worked even once, ever. Sometimes it feels like code just has to get "ripe", by lying around a bit. Computers... Hey kikemx89, you should try again - maybe it works at you too now
  12. Bonsaiheldin

    Checking if mouse is over a sprite (hover)?

    I'm having a similar problem like kikemx78: Instead of being fired just when the cursor is over a sprite, onInputOver gets only fired when the left mouse button is down, too. Otherwise the signal never fires. Using 2.5.0, JavaScript.
  13. Bonsaiheldin

    Problem with timers

    Hey! I want the weapons of a spaceship to shoot in volleys / bursts, meaning it should fire some bullets with a delay in between, reload and then repeat. I'm trying to accomplish this with simple repeat timers: // Slightly modified code fire = function() { for (var i = 0; i < weapons.length; i++) { var weapon = weapons[ i ]; if ( >= { // Reset reload delay (1000ms) = + weapon.rate; // Shoot 5 bullets with 100ms duration between, 5, function() { new Bullet(game, { x:, y:, angle: ship.rotation }); }, game); } } } My problem is that, for some odd reason, all bullets shoot from the same weapon. The timer always takes the x, y and angle values of the last given element, no matter if i iterate the weapons with a loop or do it manually for each. Even random values don't work. Any idea? It makes no sense to me
  14. Bonsaiheldin

    [Phaser][Completed] War Games: Space Dementia

    Very well done! I can only repeat what the others already wrote. I espescially love the graphics What i miss a bit are engine trails, but i guess you consciously decided against them.