Read an Xml file, create sprites from data

0 favourites
From the Asset Store
Background Story generation templates. See the Arcade demo.
  • jojoe Maybe I can just create a TileMap that has one tile for every card face. Then just load the tiles on the screen using a card index number (rather than a file name) that is in the Xml. That would make the Xml a little less human readable but that could work.

    Edit: Or maybe not. No way to dynamically create an instance of one tile from the map.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah! Tilemaps are much easier to deal with as far as loading lots of images. That is a great solution!

  • Yeah! Tilemaps are much easier to deal with as far as loading lots of images. That is a great solution!

    No, see my post above. You can't create a tile instance during runtime. Not that I can see.

  • Oh yeah locohost, they will have to load the entire sprite sheet. You cant replace just a single tile with a tilemap.

    I just buckle down and make a sprite , and load it up with a loop. Sprites seem to be the most versatile as far as positioning and scaling. Every time i try using Backgrounds as my solution, I get boxed in with limitations. If you used backgrounds you would have to load every single time a card was dealt. With a sprite, it can all be pre-loaded into frames. Then the frame just switched to the right card face when it is needed.

    There is a function called LoadIcon in the example I gave you. You can see there where i load the frame, and then switch to the next frame. (then it loops)

  • So if a card sprite sheet is 60 cards. Each card is say 150px X 300px. I make a blank sheet big enough to hold all the card image frames. I can load the card sprite sheet frames from the .png files using NWjs. We've discussed that. I can System.Create an instance of the card sprite sheet dynamically, then based on the card name from Xml data, choose the correct frame to display. I understand how all of this works so I'm good up to this point.

    My question now is about how much RAM will this require? Internally, does a the full sprite sheet get loaded into memory every time a card instance is created?

    EDIT...

    Ok from the C2 Sprite documentation...

    All instances of Sprite objects share their animations. In other words, there is a single set of images comprising the animations which belongs to the object type, and these images are referenced by instances.

    This sounds like just one sprite sheet gets loaded and all instances use this one sheet for it's frames. This makes me smile

  • Yeah! They did a nice job on the animation plugin. Before the tile-sheet object people would use the sprites to draw out the tiles of their map.

    So the Sprite is the deck, and the frames are your cards.

    If you want to save ram you might just have one card face, and card back sprite, then all your card deck sprite would have to have in it is alpha masked face values. This way you crop off the border distance.

    Then you have a face sprite, and the deck sprite on top of it showing the face value frame.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)