locohost's Recent Forum Activity

  • I have a sprite that is draggable. There are a few smaller sprites positioned on/around this sprite that need to stay in there correct spot when the parent is dragged. I have this working fine, but there is one big problem. The smaller sprites lag pretty far behind the parent when it's dragging. It looks bad. Is there a correct way to do this so they will move at the same speed as the parent?

    Thank you very much for any advice

  • Wish I would have found (or thought of looking for) this sooner...

    http://www.xmlvalidation.com/

  • korbaach Yeah I have it working now too. The issue was the </cards thing you found, plus I had a set of double-double quotes in the Xml start node. Fixed those two issues and it worked.

    korbaach

    LittleStain

    Thanks a lot guys for getting me through this. Xml is a pain the *** :-/

  • LittleStain Yeah, with korbaach helping I finally saw the </cards error. I thought for sure that was the problem. I made the fix and it still doesn't parse. Yes the Function.Param(0) definitely does have the Xml string. I can see it a variable in debug. And the Xml has the </cards> fix. I can't see why it won't parse. I may have to switch back to JSON. I can parse that for sure.

  • korbaach I was psyched for a few minutes, I thought you found the glitch. Sadly, no.

    I see nothing wrong with this simple code. This is killing me.

  • I'm including both my actual Xml data and the code. The Messages2 text object never fills so the Xml is not parsing. The function is really getting the right Xml string so I'm not sure what I'm doing wrong.

    <?xml version="1.0" encoding="utf-8"?>
    <game>
        <info>
            <name>Standard 52 Cards Game</name>
            <cardsize>
                <small width="73" height="98"></small>
                <large width="252" height="358"></large>
            </cardsize>
        </info>
        <cards>
            <card frame="0" name="Ace of Clubs" color="black" type="Clubs">Text</card>
            <card frame="1" name="Two of Clubs" color="black" type="Clubs">Text</card>
            <card frame="2" name="Three of Clubs" color="black" type="Clubs">Text</card>
            <card frame="3" name="Four of Clubs" color="black" type="Clubs">Text</card>
            <card frame="4" name="Five of Clubs" color="black" type="Clubs">Text</card>
            <card frame="5" name="Six of Clubs" color="black" type="Clubs">Text</card>
            <card frame="6" name="Seven of Clubs" color="black" type="Clubs">Text</card>
            <card frame="7" name="Eight of Clubs" color="black" type="Clubs">Text</card>
            <card frame="8" name="Nine of Clubs" color="black" type="Clubs">Text</card>
            <card frame="9" name="Ten of Clubs" color="black" type="Clubs">Text</card>
            <card frame="10" name="Jack of Clubs" color="black" type="Clubs">Text</card>
            <card frame="11" name="Queen of Clubs" color="black" type="Clubs">Text</card>
            <card frame="12" name="King of Clubs" color="black" type="Clubs">Text</card>
            <card frame="13" name="Ace of Spades" color="black" type="Spades">Text</card>
            <card frame="14" name="Two of Spades" color="black" type="Spades">Text</card>
            <card frame="15" name="Three of Spades" color="black" type="Spades">Text</card>
            <card frame="16" name="Four of Spades" color="black" type="Spades">Text</card>
            <card frame="17" name="Five of Spades" color="black" type="Spades">Text</card>
            <card frame="18" name="Six of Spades" color="black" type="Spades">Text</card>
            <card frame="19" name="Seven of Spades" color="black" type="Spades">Text</card>
            <card frame="20" name="Eight of Spades" color="black" type="Spades">Text</card>
            <card frame="21" name="Nine of Spades" color="black" type="Spades">Text</card>
            <card frame="22" name="Ten of Spades" color="black" type="Spades">Text</card>
            <card frame="23" name="Jack of Spades" color="black" type="Spades">Text</card>
            <card frame="24" name="Queen of Spades" color="black" type="Spades">Text</card>
            <card frame="25" name="King of Spades" color="black" type="Spades">Text</card>
            <card frame="26" name="Ace of Hearts" color="red" type="Hearts">Text</card>
            <card frame="27" name="Two of Hearts" color="red" type="Hearts">Text</card>
            <card frame="28" name="Three of Hearts" color="red" type="Hearts">Text</card>
            <card frame="29" name="Four of Hearts" color="red" type="Hearts">Text</card>
            <card frame="30" name="Five of Hearts" color="red" type="Hearts">Text</card>
            <card frame="31" name="Six of Hearts" color="red" type="Hearts">Text</card>
            <card frame="32" name="Seven of Hearts" color="red" type="Hearts">Text</card>
            <card frame="33" name="Eight of Hearts" color="red" type="Hearts">Text</card>
            <card frame="34" name="Nine of Hearts" color="red" type="Hearts">Text</card>
            <card frame="35" name="Ten of Hearts" color="red" type="Hearts">Text</card>
            <card frame="36" name="Jack of Hearts" color="red" type="Hearts">Text</card>
            <card frame="37" name="Queen of Hearts" color="red" type="Hearts">Text</card>
            <card frame="38" name="King of Hearts" color="red" type="Hearts">Text</card>
            <card frame="26" name="Ace of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="27" name="Two of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="28" name="Three of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="29" name="Four of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="30" name="Five of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="31" name="Six of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="32" name="Seven of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="33" name="Eight of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="34" name="Nine of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="35" name="Ten of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="36" name="Jack of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="37" name="Queen of Diamonds" color="red" type="Diamonds">Text</card>
            <card frame="38" name="King of Diamonds" color="red" type="Diamonds">Text</card>
        </cards
    </game>
    [/code:3jtmnrzt]
    
    [img="http://i.imgur.com/Hd7drLc.png"]
  • 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

  • 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!

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

  • 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.

  • System.create the background tiles one at a time in your loop, then load the URL right after you spawn it.

    Or give them a instance variable like "Type", so you can choose which tile you load it into with a system.pick by comparison: background.Type="Thumbail" (or whatever)

    sorry my english is not so great

    Your English is pretty good

    This might be the way to go. I'll look into this.

  • or a single sprite and change the frames, the URL will load into the current frame

    Ok I think I follow this part. I could create one "cardSprite" that has the size for 60 cards, but the sprite sheet can be completely blank. Then each time I create an instance of cardSprite, increment the frame, then load the image into that frame. I think this will work right?

    Wait...

    But ultimately the cardSprite will eventually contain every card image in every frame in every instance of each card on the screen. So I may as well just start with a cardSprte that has every card image and then just switch frames based on the Xml data. it's no difference. Am I thinking right?

  • jojoe Not sure I follow "Use a background". Can I place many instances of one small TiledBackground object (say it's 100px X 200px, whatever, small) on the layout, load it's image from a file using NWjs and then this will not change the images for the other existing instances?

locohost's avatar

locohost

Member since 19 Sep, 2014

None one is following locohost yet!

Trophy Case

  • 10-Year Club
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

14/44
How to earn trophies