mariogarranz

Members
  • Content Count

    190
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    mariogarranz reacted to fariazz in How to load a JSON file?   
    Thanks that worked! If it helps anyone, this is how you can then retrieve the loaded object:
    // in preload() this.load.json('levelData', 'assets/level.json'); // in create() let data = this.cache.json.get('levelData');  
  2. Like
    mariogarranz got a reaction from ComputDroid in Object has no method 'preUpdate' when scaling the game   
    I'm getting this error when my game is scaled in 1.2:   Uncaught TypeError: Object [object Object] has no method 'preUpdate' phaser.js:25634 Phaser.Stage.preUpdatephaser.js:25634 Phaser.Game.updatephaser.js:28900 Phaser.RequestAnimationFrame.updateRAFphaser.js:43151 _onLoop     The error doesn't appear when playing without any kind of scaling.   The function causing the error is this one: Phaser.Stage.prototype.preUpdate = function () {        this.currentRenderOrderID = 0;    //  This can't loop in reverse, we need the orderID to be in sequence    var len = this.children.length;    for (var i = 0; i < len; i++)    {        this.children[i].preUpdate();    }} And this is how I am scaling the game:
     
     
    this.game.scale.scaleMode = Phaser.ScaleManager.EXACT_FIT;this.game.scale.setShowAll();this.game.scale.refresh();
  3. Like
    mariogarranz reacted to cloakedninjas in roundPixels on a per-Sprite basis?   
    Well... As a dirty hack I've added the following to my Cloud sprite class:
    _renderWebGL(renderSession:PIXI.RenderSession) { renderSession.roundPixels = false; super._renderWebGL(renderSession); renderSession.roundPixels = true;}_renderCanvas(renderSession:PIXI.RenderSession) { renderSession.roundPixels = false; super._renderCanvas(renderSession); renderSession.roundPixels = true;} This does the trick, but ideally it would be a property on the Sprite itself, along with checking the global setting: https://github.com/photonstorm/phaser/blob/c9c85330ab60547b39ba4c9400c258ed7fb2a317/src/pixi/display/Sprite.js#L423
  4. Like
    mariogarranz got a reaction from Tilde in TweenManager.frameBased not working as expected?   
    After upgrading some games to Phaser 2.4.3 we noticed some animations were suddenly playing really fast or really slow (depending on devices). Some bug fixes regarding this were added on 2.4.4, but the problem was still there.
     
    This bug seemed to affect only Tween animations so I checked the docs and found this value:

    TweenManager.frameBased:
     


    According to this, the default behavior should be the same as in previous versions of Phaser, however it seemed to be the opposite, since the animation duration was now being dependant on the speed of the device.

    I tried setting frameBased to true and everything appears to work fine now (even though I'm still sending the time parameter as milliseconds, not in frame numbers).

    Am I missing something here or is the functionality bugged?
  5. Like
    mariogarranz reacted to feudalwars in Lots of sprites, improve performance   
    Have you tried switching the canvas renderer to webgl or 2d? webgl typically gives a performance boost but I suppose it depends on what you're doing. You can also try forcing 2D (by setting the rendered property to Phaser.CANVAS) instead of auto. 
     
    Phaser should be able to handle 100-200 sprites easily, especially if there is nothing in the updates function. I would examine other factors. Just because the game is much faster with fewer sprites, doesn't necessarily mean the sprite # is the problem. There might be something else in the game affecting performance and increasing the sprite # puts you over the threshold of what the device can handle. 
     
    What are you using for the environment, tiles? How many? I would examine all displayObject containers and check for large quantities of game objects, because that's the number 1 cause of memory leaks: too many objects. But 100-200 is not a lot. 
     
    How does performance compare on PC? Can you send a link? It also might be worthwhile to run the Chrome javascript profiler - that will tell you exactly which processes are sucking up resources. 
  6. Like
    mariogarranz reacted to klg in Lots of sprites, improve performance   
    Hi mariogarranz,
     
    I've almost the same situation as you do and haven't been able to figure out the solution. I'm not sure why there is no performance boost when I set visible or renderable property to false.
  7. Like
    mariogarranz reacted to ben_a_adams in How to make physics "hard"   
    There's a good talk from Glenn Fiedler about games physics and what makes things squishy, feel hard, light, heavy and issues and consequences from this http://gdcvault.com/play/1022195/Physics-for-Game-Programmers-Networking
  8. Like
    mariogarranz reacted to rich in Arcade Physics: Invisible sprites not colliding   
    This is normal - Pixi skips all 'visible false' Sprites from the update transform, so their position never changes or propagates, where-as alpha 0 sprites are just skipped for rendering (you could equally do Sprite.renderable = false, which is a cleaner way of doing it imho). This won't be changed in any Phaser 2 release as it has been like this for years now so would be too much of a change. It's something we did address in Phaser 3 however (the issue is semantic really, i.e. the naming of things vs. expected behaviour, rather than technical).
  9. Like
    mariogarranz got a reaction from olkina in Phaser Performance with large resoluton   
    Are you using WebGL renderer? I noticed I have similar issues with WebGL in some mobile devices.

    My guess is it's something related with texture sizes or power of two dimensions (I use some BitmapData that are not powers of 2 often), but if you're using WebGL switching to CANVAS and see if it works could be a first good step.
  10. Like
    mariogarranz reacted to rich in Is this legal? game.load.image(...)   
    Depends when you load it.
     
    If you do this in the same preload block, then the 2nd call will be ignored unless you set the overwrite parameter to true:
    game.load.image("dude", "blah.png", true); If you do this some time later, i.e. in another State, then it will replace whatever was in the image cache matching that ID, but the original image object is left un-touched. Under Phaser 2.3 if this happens the original image is destroyed first and removed from the GPU.
  11. Like
    mariogarranz reacted to richpixel in Interesting discovery: anchor vs pivot   
    I'm not sure if this has been brought up before...
     
    This morning I discovered some 'tearing' in my images. A visible warping across the images which looks like it's related to WebGL breaking the image into triangles and not lining them up properly:
     

     
    - The image has the smoothed property set to false, in order to get a crisp, unscaled look.
    - It's not being scaled either by Phaser or the Canvas.
    - The image above has anchor set to 0.5 on x, ie. myImage.anchor.set(0.5, 0);
     
    This struck me has a 'half-pixel' kind of problem, so I made sure x,y coords were rounded off but it didn't help.
     
    But then I tried the PIXI pivot property:
     
    myImage.pivot.set(Math.round(myImage.width * 0.5), 0);
     
    And this solved the problem... I don't know what's happening internally to make this work, but I just wanted to share this fix!
     
    btw running Phaser 2.2.2, PIXI 2.2.0, WebGL
     
     
     
  12. Like
    mariogarranz reacted to shmikucis in Game editor on Phaser   
    Hi Mario,
     
    thanks for good words
     
    You can import all files by drag&drop to file tree section in source editor (screenshot below)
     

     
    Unfortunately I don't know your current workflow and can't give universal answer. But one thing is for sure. You will have to load all assets through editor instead of preload function which most probably you are using now. It may happen that sprite texture keys differs which then should be manually renamed. 
     
    All the rest should be easy adjustable. Groups, sprites, texts, tile layers are created with mt.create(objectName) and you handle them as normal Phaser objects.
  13. Like
    mariogarranz reacted to pxam in Identifying Tiled objects   
    Hi,
    sounds like you use the object properties in the map instead of tileproperties in the tileset.
    set a class value or/and a custom hitbox in there.
    use a tile for every type of enemy/object so you can have icons or a little preview image in Tiled.
    loop through map.tilesets[0].tileProperties and save the gid and the tileproperties so you can create them via map.createFromObjects with the custom/tile class
  14. Like
    mariogarranz got a reaction from tips4design in Intersect between sprite and line Physics.Arcade   
    Yeah but if you look into the getRayCastTiles method you will see how it works:


    First, it generates a set of coordinates from the line:
    var coords = line.coordinatesOnLine(stepRate);
    Then, it checks every tile (which, with collision enabled, I think is a Sprite) with the coordinate list:
      if (tile.containsPoint(coord[0], coord[1])) And does whatever, in this case store the tiles into an array.
     
  15. Like
    mariogarranz reacted to cvshepherd in How to make an animation of a sprite with several spritesheets?   
    Hi Nicholls,
    I needed this too, for a project of mine. I can't access the code at the moment, but I ended up with a custom animation class, wich consisted of multiple phaser animations, each calling .play() on the next one in their .onComplete(). Was very little code, and worked well. Hope this helps.
     
    Cheers
  16. Like
    mariogarranz reacted to lewster32 in Different sprites from cropping a single texture.   
    It's a bit of a hack but you could treat it as a texture atlas and generate the JSON data object part of the atlas yourself, feed it into the game.load.atlasJSONArray function as the last parameter (atlasData) and have it work as needed. The other way (and probably the better and more 'correct' way) would be to use BitmapData objects and copy parts of the full image to these as needed using the copyPixels function.
  17. Like
    mariogarranz reacted to rich in Phaser 2.1.3 "Ravinda" is Released   
    Just to clarify my message above for anyone not used to how the dev branch works: when I fix issues in dev I very rarely create new build files (because I don't need to in order to test). Which means if you're working out of dev I strongly suggest using the provided grunt task to build your own local copy. It will place the files in a 'dist' folder, which is excluded from git so won't interfere with future pulls. Or keep an eye on the contents of the build folder in the repo, and if you can see I've committed some pre-built files, use those. Just know they'll nearly always be behind the actual dev status a little.
  18. Like
    mariogarranz reacted to hackenstein in Sprite.crop question   
    I noticed the same problem with spritesheets. The whole spritesheet will be cropped instead of the currently visible frame. My guess is that spritesheets are internally cropped to show the individual frames. So cropping spritesheets with more than one frame will lead to conflicts and result in unexpected behaviour.
  19. Like
    mariogarranz reacted to rich in Are there any plans to enable protected code on HTML5?   
    To actually answer your question though: I don't expect to see source code or image level DRM any time soon, and I don't know of any W3C proposals even considering it outside of video / EME. You can see the discussion on that here: http://www.w3.org/community/pua/wiki/Digital_Rights_Management
  20. Like
    mariogarranz got a reaction from valueerror in Pointer isDown stays true if the pointer leaves the canvas   
    Sure, I already opened an issue on GitHub.
  21. Like
    mariogarranz reacted to lewster32 in Does Phaser handle object visibility according to camera?   
    The Sprite.inCamera property will tell you if a sprite is visible or not, but beware that each time it's checked, the sprite's bounds are recalculated - you'll have to determine how expensive this operation is compared to allowing the sprites to be rendered outside of your camera bounds.
  22. Like
    mariogarranz got a reaction from analytik in Center BitmapText   
    Yeah sure, my solution is as simple as this:
     
    Phaser.BitmapText.prototype.anchor = new Phaser.Point();Phaser.BitmapText.prototype.update = function(){this.pivot.x = this.anchor.x*this.textWidth;this.pivot.y = this.anchor.y*this.textHeight;}; Just took what we had in Phaser previous to version 2 and added it back, with a very little change in width and height source variables, because they are different in Phaser 2.
    So I have this inside a file BitmapText.js that I just include in my games so I can update Phaser without losing this funcionality.
    Hope it helps some of you guys
  23. Like
    mariogarranz reacted to esteban.guelvenzu in Center BitmapText   
    Mario, I like the way you implemented the anchor, I just added an if:
    Phaser.BitmapText.prototype.update = function(){ if (this.anchor != null){ this.updateTransform(); this.pivot.x = this.anchor.x*this.textWidth; this.pivot.y = this.anchor.y*this.textHeight; }}; that way if you don't define an anchor, then the pivot is the default one, and the anchor variable belong tho the object, not the class.
  24. Like
    mariogarranz reacted to rich in Detect state ready   
    Break it up a bit. What you will find for example is that if you create a mass of objects, or do things which cause texture updates, then you'll get a brief delay while all of that happens. So see if you can do a bit of it during the preload, see if you can perhaps start the game off with something that doesn't require specific timing, for example simply fade an image on for half a second. As long as the image was obtained really early, say via the Boot state, then it will render instantly - and although other tasks may not yet be completed that fade should give you enough time for everything to have settled down a bit. You may even be able to hide it behind something as simple as fading the preloader bar away.
  25. Like
    mariogarranz reacted to rich in Detect state ready   
    update and render are not started until create has been called first. However it's entirely possible for you to launch expensive async processes within create. Decoding audio for example is a classic one. But just generally creating masses of images can sometimes be enough to cause a slight delay as they are all uploaded to the GPU - this is very device specific though and easy to mitigate by carefully loading and pre-seeding the GPU. It's also impossible to get any kind of event from the hardware to know when this process has finished, so Phaser couldn't report it back even if it wanted to.
     
    update will always fire before render, as that's the order in which they're supposed to happen.