locohost's Forum Posts

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

  • Oh but wait, I think when you load the sprite image from url, it will change the image for every sprite on the screen, not just one particular instance. So you still would need a many, many unique sprite instances for each different card. Damn I think this kills it.

    We need to be able to create an instance of one sprite, call it "cardSprite", then load that cardSprite instance image from the file and not change the image of every other cardSprite instance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • jojoe Still reading but it looks like just the ticket! Thank you!

  • Interesting. I'll look at that. Thank you!!

  • I know c2 can load images in, they just need a url which can be stored with all the data in text or json.

    Yes this is true, I've considered this, however I'd need to either distribute a Node/Express web app with the game just serve the images. Or I'd have to host the images on a web site, which is possible but not practical. Plus that means the game will never work offline.

    Someone must have made a plugin to load images from a local folder right? I'm searching...

  • I do know the "create a giant sprite sheet that has every card face" option, then you can select the sprite frame by an Id. But this means every card sprite in play is huuuuge because every card is the entire set of all cards! Wouldn't this use a S-ton of RAM when you get a bunch of cards out?

  • Create a C2 app that is user customizable in that she/he can provide a folder of images and an Xml file. The Xml specifies certain set of game elements to create during runtime that correspond to the image files. Think "a TCG deck" for example.

    A C2 sprite cannot be dynamically created by a name/Id. So there is literally no way to do this in a C2 app other than hard coding a "card factory" function with an enormous block of if/thens?

    Thanks for any tips

  • Hey I just found this... http://peerjs.com

    Yeah this very awesome. Someone wrap PeerJS up in a C2 plugin and I'll pay your for it

    No, seriously I will pay

  • Well that's not totally true, you could use Skype or Google Hangouts. Either of those would work too. But Skype calls can get flaky. I'll be testing Discord sometime soon. I'll LYK how it works. Fingers crossed

  • It appears to be the only option for C2 game right now.