A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Management of sprites

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    2

    Management of sprites

    Hi there, New to the community and hoping to learn a lot from here.

    I'm currently working on a little side project with a friend. The game is a very simple tactics game that uses external .PNG for sprites. We're using an XML to call out those files as to reduce noodling in flash to add new elements.

    I'm wondering if this method slows down flash games as opposed to importing the files directly into the project.

    Also I'm looking into doing the same for animated sprites, lets say a character walk cycle (6frames) saved off into 6 separate PNG files. Or is there a better way to do this?

    Ive seen people post sprite sheets that contain all character animations, is it possible to use such a sheet within flash? Example: 6 frames each 10x10px so the sheet is 60x10px. When a walk is initiated, it cycles through the sheet for that action.

    Basically I'm hoping to create a system or a game engine where adding new animations is very modular and controlled externally through XML files.

    Any thoughts?

  2. #2
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,377
    I'm wondering if this method slows down flash games as opposed to importing the files directly into the project.
    I wouldn't call it "slowing down" Flash; those graphics have to downloaded at some point so whether you put them into the .swf or import them at runtime is irrelevant.

    Also I'm looking into doing the same for animated sprites, lets say a character walk cycle (6frames) saved off into 6 separate PNG files. Or is there a better way to do this?
    Not much better, in my opinion. Personally, I'm a fan of embedding graphics rather than importing, but as I said about, the difference is neglible.

    Ive seen people post sprite sheets that contain all character animations, is it possible to use such a sheet within flash? Example: 6 frames each 10x10px so the sheet is 60x10px. When a walk is initiated, it cycles through the sheet for that action.
    Absolutely! Mind you, the process is a bit different between AS2 and AS3. In AS2 you simply attach a copy of your bitmap to a movieclip, put that movieclip into your character clip, and give the character movieclip a scrollrect equal to the size of your frame (10x10 in your case). Then each frame, simply move the bitmap-holder clip by the width of your frame. Here's example AS2 code:

    Code:
    // for a sprite sheet 60x10 named "walkcycle"
    
    var c:Movieclip = _root.createEmptyMovieClip("char", 0);
    var b:BitmapData = BitmapData.loadBitmap("walkcycle");
    c.bHolder = c.createEmptyMovieClip("bHolder", 0);
    
    var rect:Rectangle = new Rectangle(0, 0, 11, 11);
    
    c.scrollRect = rect;
    
    c.onEnterFrame = function() {
    		this.bHolder._x -= 10;
    		this.bHolder._x %= -60;
    		this._x += 10;
    }
    You'll see that the clip will move 10 pixels to the right each frame while the inner layer moves 10 pixels to the left relative to the character clip.

    Here's a better, more advanced example I did for a project in AS2. In the drop down box, you can see that each of the characters is comprised of a single sheet that allows for 4-directional movement.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    Thank you, I'll give this a shot in AS3

  4. #4
    Isometric Engine AS3
    Join Date
    Apr 2009
    Location
    France
    Posts
    18
    I have an other opinion on it. First of all it s better to lad graphics dinamicly because you won't need to recompile if you change the images and it will be much more easier to add or change textures. Yes, you can use set of graphics i do it on my isoEngine coded on AS3; it s open source so you can see how i load png and how i use it to make animations. My secret is the use of addFrameScript, i use for each frame a different copypixels of the png. The better way to learn is to look at my package there is 3 classes called DataManager (load of Xml and the load of png), IsoGraphic which call TileMaker to create the MovieClip and then Animate the clip.
    The link to the package is here :http://sourceforge.net/projects/isoengineas3/
    The ling to the engine to see the result is here:http://angelstreetv2.free.fr/as3/IsoEngine/

  5. #5
    Isometric Engine AS3
    Join Date
    Apr 2009
    Location
    France
    Posts
    18

    IsoEngine AS3

    New version of IsoEngine an IsoEditor.
    Try it online here:
    - http://angelstreetv2.free.fr/as3/IsoEngine/
    - http://angelstreetv2.free.fr/as3/IsoEditor/

  6. #6
    Member
    Join Date
    Aug 2010
    Posts
    65
    copypixels is faster than scrollrect or GAS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center