Jump to content

ritherz

Members
  • Content Count

    12
  • Joined

  • Last visited

Reputation Activity

  1. Like
    ritherz got a reaction from Tom Atom in Spriter skeletal animations in Phaser   
    I have finally managed to replace The Hero example stuff with my own sprite!!  I had to rename the entity in the xml I generated, and actually create a sprite atlas for the images I am using (thanks ShoeBox).
    I totally see what you mean by the export coordinates/axis issues.  But, I finally figured it out!  You basically have to set pivot_y to 1 - pivot_y for all object tags.  Then the animation works well, and is not distorted like my previous attempts were.
    <timeline id="2" name="Right Arm"> <key id="0" spin="0"> <object folder="0" file="2" x="120" y="10" pivot_x="0.982419" pivot_y="0.252345" angle="89.949121"/>  I think I may write out a newbie guide on how to use this awesome tool!
    LOTS OF EDIT, as I was figuring this out.

     
  2. Like
    ritherz reacted to Tom Atom in Spriter skeletal animations in Phaser   
    @ritherz: working with Typescript is easy and if you use JS, you will have no problems to read TS - it is still more or less JS, but with types and more C#/Java organization when it comes to objects and classes.
    To use the code, do what I suggested above to create "lib" (delete all SpriteExample). Then create your Phaser game and in Preload state put this:
    preload() { // test - load atlas with animation parts this.load.atlas("TEST", "Atlas.png", "Atlas.json"); // load xml animation data // this.load.xml("TESTXml", "TEST.xml"); // or json data - depending on your Spriter export this.load.json("TESTJson", "TEST.json"); } This is just regular Phaser loading of atlas and xml/json
    Then in crate method of your state (Test state in source) put this:
    // create object that understands loaded xml or json and can create internal object structures from it. This class can be used to precess many xml/json files with Spriter data var spriterLoader = new Spriter.Loader(); // create object that takes loaded xml or json and wraps it into SpriterFile (SpriterXml and SpriteJSON are descendants of SproiterFile) //var spriterFile = new Spriter.SpriterXml(this.cache.getXML("TESTXml")); var spriterFile = new Spriter.SpriterJSON(this.cache.getJSON("TESTJson")); // process loaded xml/json and create internal Spriter objects - these data can be used repeatly for many instances of the same animation var spriterData = spriterLoader.load(spriterFile); // Spriter anim is in SpriterGroup object, which is Phaser.Group - here you are creating one instance of Spriter animation from loaded data with atlas "TEST" this._spriterGroup = new Spriter.SpriterGroup(this.game, spriterData, "TEST", "Hero", 0, 100); this._spriterGroup.position.setTo(420, 400); // add it to Phaser scene graph this.world.add(this._spriterGroup);  ... that is all.
     
  3. Like
    ritherz reacted to RaphaelStary in How do you render sprites faster on old mobile devices   
    (my post is not phaser specific, I never used it.)

    I think your sprite sheets are too big for low memory devices.

    a single sprite sheet of yours is not too large according to https://discussions.apple.com/thread/4975106
    ... and apple removed the image size information from its official docs here https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html
    so I would guess there is no hard image size limit in the newest version of mobile safari anymore.

    BUT nevertheless I think 2 fairly large images are too much for low memory devices using cavas 2d rendering. You could try it with only one, and see if it solves your performance problem.

    I experienced with canvas 2d rendering that you get very bad performance with more than one big atlas/sprite-sheet. When I'm using large atlases/sprite sheets I try to put really everything into one file to get the best performance possible, while keeping the one image below the ios mobile safari size limits (but I don't know if they still exist in iOS 9 as stated above).
  4. Like
    ritherz reacted to DonFrag in Mobile performance - tips && tricks   
    how can you add precached functions when you extend Sprite?
  5. Like
    ritherz reacted to SolarJS in Mobile performance - tips && tricks   
    Sure, here's how it's done above:
    classABC = function () {}classABC.prototype.myMethod1 = function () { console.log('myMethod'); } classABC.prototype.myMethod2 = function () { console.log('myMethod2'); } Now change this to:
     
    var myMethod1F = function () { console.log('myMethod1'); };var myMethod2F = function () { console.log('myMethod2'); };classABC = function () { return { myMethod1: myMethod1F, myMethod2: myMethod2F } } You might also consider to leave classes at all, if you don't have many balls to handle or do other fancy stuff with it. Know your tools
  6. Like
    ritherz reacted to drhayes in Can I load assets in the background?   
    I think the OP means: the user is going to spend a couple of seconds on the main menu. Why not shorten the first loading bar by a significant fraction and show the intro/main menu immediately, then load the rest of the stuff. Then, on state transition to actually playing the game, show a loading bar, if needed, for the rest of the assets.
     
    Looking at the StateManager my initial answer is... maybe? In StateManager#preUpdate it resets the loader on preload. So, it expects all loading stuff to be in the preload callback and clears anything that might be loading already. However, if something were already in the cache at that point the loader would have nothing to do so it would load that resource really quickly if you loaded it again... maybe?
     
    If you don't want that to happen you can set Loader#resetLocked to true. No reset, so I *believe* it'll just keep loading files. Haven't tested it, though.
  7. Like
    ritherz reacted to tips4design in Can I load assets in the background?   
    For game.loadspriteifnotalreadyloaded() you could simply check if the texture is in cache or not.
     
    The problem is what happens if a sprite only loads partially (eg; 90%) when the user switches state? Probably the sprite would have to be loaded again.
     
    Now, game.loadSpriteInBackground() would be a better idea. And I think you can do this by creating a global Phaser.Loader entity (global to the game, not local to a state), or use the existing global Loader. Now, what you should do, is in your state, instead of preloading the stuff, wait for the stuff required for this state to load (eg: check that all textures required for the current state are in the cache). 
  8. Like
    ritherz reacted to drhayes in Can I load assets in the background?   
    The loader's still available in the later stages of a state's lifecycle; I'd say try the existing stuff before writing new code.
  9. Like
    ritherz reacted to gregkarber in My game works, but I want it to work faster   
    I think I implemented your suggestion! It still could run a little faster, though...
    function circleCreate() { var circleSize = Math.random() * 50 + 60; asteroidCircle = game.add.bitmapData(100, 100, "asteroidBit", true); asteroidCircle.circle(50, 50, 50, "#FFFFFF") asteroidGroup = game.add.group(); asteroidGroup.createMultiple(100, asteroidCircle); }function asteroids(x, y) { //console.log("asteroid at " + x + "," + y); var circleSize = Math.random() * .5 + .5; asteroid = asteroidGroup.getFirstDead(); asteroid.reset(x,y); asteroid.anchor.x = .5; asteroid.anchor.y = .5; asteroid.scale.x = circleSize; asteroid.scale.y = circleSize; game.physics.p2.enable(asteroid, false); asteroid.body.clearShapes(); asteroid.body.addCircle(circleSize * 50); asteroid.body.setCollisionGroup(asteroidCollisionGroup); asteroid.body.collides([shipCollisionGroup, asteroidCollisionGroup]); asteroid.body.debug = true; asteroid.body.velocity.x = Math.random() * 50 - 25; asteroid.body.velocity.y = Math.random() * 50 - 25; this.spacerocks.add(asteroid); }
  10. Like
    ritherz got a reaction from tips4design in Can I load assets in the background?   
    If I have a menu screen game state (where presumably users would probably spend a few seconds navigating to what they want to do), can I load the assets for the actual game while having the menu screen already displayed and working?
     
    So it would look something like this:
     
    Preload menu state assets. Display menu state. While in the menu state (allowing navigation still), the browser fetches the assets for the next state ("playing the game" state). Player clicks "play". Load the rest of the game state assets that haven't been loaded in step (3) Change to game state.  
    Maybe this isn't even possible since javascript is not multi-threaded heh, but I figure I should at least ask the pros!
     
    I'm trying to think of ways that my game can display the menu screen a bit quicker than it does now, so other ideas are welcome as well, but I think the asset downloads is probably the biggest chunk of time.
×
×
  • Create New...