Jump to content

Camera.screenView is never adjusted?


InsaneHero
 Share

Recommended Posts

I just tried to use the Sprite.inCamera property and found that in my game it is always true, even when it shouldn't be.

After poking around in the phaser source for a bit I noticed that the Camera.screenView rectangle that it depends on is set once in the Camera constructor, then (apparently) never changed again.

Surely this should update every time the camera moves?  Or am I missing something obvious (again!)?

 

If I'm right and this will always be true, it will have some serious implications for Phaser performance as almost all culling type operations depend on it.  And if I'm wrong, then I'd quite like to know what I'm missing because I want my audio effects to skip when the breaking window is off-screen!

    // create function for flames coming out of a breaking window    create: function(o, x, y, speed)    {        this.owner = o;        this.sprite = Game.behindLayer.create(x, y, 'fire');        this.sprite.anchor.setTo(0.5, 1);        this.sprite.animations.add('burn');        this.sprite.animations.play('burn', 10, true, false);        if (MissionControl.sfxWindowExplode && this.sprite.inCamera)            MissionControl.sfxWindowExplode.play();    },
Link to comment
Share on other sites

Because Pixi Sprite.getBounds used to return a local bounds, not in world space. I will fix that, but even if I do it still won't work because Pixi no longer takes the renderable property into account! It's just ignored now (see here) - so I'll need to submit a PR for that too.

 

Now you can see why I asked you to work on what you're working on next ;)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...