feudalwars

Members
  • Content count

    540
  • Joined

  • Last visited

  • Days Won

    2

feudalwars last won the day on May 17 2015

feudalwars had the most liked content!

3 Followers

About feudalwars

  • Rank
    Advanced Member

Contact Methods

  • Website URL
    http://www.feudalwars.net

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

1,602 profile views
  1. Here's what I do to detect the actual visibility change (as the title of this thread asks): var vis = (function(){ var stateKey, eventKey, keys = { hidden: "visibilitychange", webkitHidden: "webkitvisibilitychange", mozHidden: "mozvisibilitychange", msHidden: "msvisibilitychange" }; for (stateKey in keys) { if (stateKey in document) { eventKey = keys[stateKey]; break; } } return function(c) { if (c) document.addEventListener(eventKey, c); return !document[stateKey]; } })(); vis() returns true if the tab is in focus. This is a much more reliable way than setting a boolean on pause/resume, as you might be pausing/resuming your game state in other code.
  2. there is a difference between detecting when the game is paused and detecting when the tab is no longer active (i.e. out of focus). Why is this distinction important? Suppose I pause/resume the game in many different ways. So auto pausing on visibility change is just 1 way. Therefore, there should be a way to detect visibility change without it being tied to game.paused.
  3. In fact, it seems the repeat counter is always at zero, no matter what i do. Even if i set a tween to repeat 50 times.
  4. Oh, it looks like i just need to pass game.tweens instead of Phaser.TweenManager. If I read the repeatCounter on tweens that are set to repeat infinity (-1), it always reads "0," so I guess that approach won't work.
  5. Hmm, I get: Uncaught TypeError: Cannot read property 'push' of undefined at Function.add (phaser-2.6.2.js:64325) at Phaser.TweenManager.add (game.js:336)
  6. Nice. But is there an easy way to discriminate between infinite looping tweens (tweens set to repeat -1) and non-infinite? I would only want to create references to tweens that repeat forever.
  7. Suppose I want to pause all tweens or resume all infinite repeating tweens on a given sprite? Is there a non-messy way to do that (i.e. one that does not involve searching through every possible tween and checking the target)? Perhaps there is some way to modify game.add.tween so it automatically pushes to an array (stored as a property on the sprite object). I understand it could get really messy if you are adding lots of tweens, but suppose you only want to store tweens that repeat infinitely? Of course, I can manually create the references, but my game has so many tweens added in different places, it would be a big effort. It would be much more ideal to modify game.add.tween so it automatically creates the references.
  8. Played this game tonight (2v2, hard AI): Learn more about Strike Tactics on the official Strike Tactics website.
  9. I don't understand. What is the solution to this? Can you please explain your code pen? Your codepen has zero width. And what does loading have to do with it if the data is already there?
  10. P.S. It has nothing to do with the fact i am using a texture atlas instead of a standard image as I just tested and am getting the same problems with the standard image. i can't figure out for the life of me what might be different from your example and my implementation!
  11. I take that back, it has nothing to do with rendering to a render texture. It's PIXI.WebGLRenderer.renderDisplayObject that is causing the error: 256phaser-2.6.2.js:16593 WebGL: INVALID_OPERATION: uniform2f: location not for current program PIXI.PixiShader.syncUniforms @ phaser-2.6.2.js:16593 PIXI.WebGLFilterManager.applyFilterPass @ phaser-2.6.2.js:19745 PIXI.WebGLFilterManager.popFilter @ phaser-2.6.2.js:19690 PIXI.Sprite._renderWebGL @ phaser-2.6.2.js:15604 PIXI.DisplayObjectContainer._renderWebGL @ phaser-2.6.2.js:15104 PIXI.DisplayObjectContainer._renderWebGL @ phaser-2.6.2.js:15104 PIXI.DisplayObjectContainer._renderWebGL @ phaser-2.6.2.js:15104 PIXI.WebGLRenderer.renderDisplayObject @ phaser-2.6.2.js:17500 PIXI.WebGLRenderer.render @ phaser-2.6.2.js:17466 updateRender @ phaser-2.6.2.js:36387 update @ phaser-2.6.2.js:36308 updateRAF @ phaser-2.6.2.js:61979 _onLoop @ phaser-2.6.2.js:61962 phaser-2.6.2.js:16593 WebGL: too many errors, no more errors will be reported to the console for this context. PIXI.PixiShader.syncUniforms @ phaser-2.6.2.js:16593 PIXI.WebGLFilterManager.applyFilterPass @ phaser-2.6.2.js:19745 PIXI.WebGLFilterManager.popFilter @ phaser-2.6.2.js:19690 PIXI.Sprite._renderWebGL @ phaser-2.6.2.js:15604 PIXI.DisplayObjectContainer._renderWebGL @ phaser-2.6.2.js:15104 PIXI.DisplayObjectContainer._renderWebGL @ phaser-2.6.2.js:15104 PIXI.DisplayObjectContainer._renderWebGL @ phaser-2.6.2.js:15104 PIXI.WebGLRenderer.renderDisplayObject @ phaser-2.6.2.js:17500 PIXI.WebGLRenderer.render @ phaser-2.6.2.js:17466 updateRender @ phaser-2.6.2.js:36387 update @ phaser-2.6.2.js:36308 updateRAF @ phaser-2.6.2.js:61979 _onLoop @ phaser-2.6.2.js:61962 P.S. I did try your example on Phaser 2.6.2 and it worked so the phaser version isn't the problem.
  12. If I set "frag" to a global variable instead of re-declaring it each time i create a new sprite, i get slightly different results. the units are still invisible but when my game code tried to draw them to a render texture, I get a webgl error: INVALID_OPERATION: uniform2f: location not for current program The callstack for that begins when Phaser attempts to render the sprite (with the filter) to a render texture.
  13. Hmm, whenever I apply the filter, the sprite becomes invisible. Any idea what might be causing that? The only thing different from your example is the fact that my sprites are loaded from a texture atlas... my sprites also have animations so are set to a particular frame (portion of the texture) at any given time.
  14. When I add the filter to a sprite, it disappears. I think it has something to do with the fact that the sprite texture is a texture atlas so the sprite is only using a small portion of that texture (its frame).
  15. That was my first inclination but I didn't know enough about fragment shaders to figure it out. Looks like you did though. This works perfectly! The only thing I am afraid is that adding a custom filter for each sprite would have big performance implications... I'm thinking I will just create 1 filter (with a hue shift) and make it the size of the largest sprite. No harm in giving smaller sprites a filter that is much bigger than they are, right? It might be more performant than creating a new filter for each different size.