Javascript SDK template - r124 update

0 favourites
  • 12 posts
From the Asset Store
Fruit Slicer Template & Quality fruit and slice graphics (c3p,png,illustrator files)
  • Hi all,

    The Javascript SDK template has been updated for r124. Download here:

    http://www.scirra.com/downloads/javascript-sdk-template.zip

    <font size="5">Changes</font>

    • Plugin and behavior templates include saveToJSON() and loadFromJSON() template methods. You must implement these for your plugin or behavior to support full-state save/load or the Persist behavior. Usually this is relatively simple (see the comments - you just need to return a JSON object in the save method, then read from the same object in the load method).
    • Plugin and behavior templates now include an onDestroy() method by default. You should drop references or recycle objects for GC in this method, since the runtime will keep the actual instance around for recycling.
    • Some .c2addon samples are bundled, as well as the source folders to zip to create .c2addon files. This should help you easily create .c2addon packages.
  • Ashley

    I love the save/load system. I will support this feature as soon as possible.

  • Ashley

    I have a Photon Cloud multiplayer behavior on the go. Intuitively (which means I haven't thought through this in detail), I'd think it's not appropriate to implement save/load since the game state is not fully contained within any single client that might be wanting to do a save/load?

  • As the r124 release notes pointed out, generally network stuff isn't included in savegames. Things like the AJAX object and WebSockets are completely skipped when saving and loading, because it doesn't really make sense to save or load them. The same goes for any multiplayer features - it really doesn't make sense to save on the client, since the server ought to have the only real instance of the game. So yes, no need to implement save or load there.

  • ... So yes, no need to implement save or load there.

    Thanks for your confirmation, Ashley (and for saving (!) me a bit more work :) )

  • var inst = this.runtime.getObjectByUID(uid);

    It's cool~ C2 has a global UID to inst table now.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley

    Question:

    Will it cause performance loss if I use "this.runtime.getObjectByUID(uid)" to get instance reference to replace saving instance reference directly?

    In case of saving instance reference directly,

    It need to check if the reference was destroyed in destroyed callback. And, this destroyed callback need to be released when this behavior/plugin had been destroyed.

    In case of saving instance reference by UID then pick instance reference by calling "this.runtime.getObjectByUID(uid)",

    It only need to check if the return reference is not null.

  • I'm not exactly sure what you're trying to do... and you should still do things like reset UIDs when the objects are destroyed as a good practice. However getObjectByUID should be fast (it's based on accessing object properties, if you look it up it's 1 line), and often storing instances by UID makes it easier to support saving/loading too.

  • Ashley

    "storing instances by UID makes it easier to support saving/loading"

    Totally agree.

    Anyway, thanks for giving me "getObjectByUID" method.

  • Ashley

    Array or dictionary objects could not add any behavior, how to "no save" these kinds of object?

    BTW, it might be more flexible if plugin which is "object" type (for example, Array or dictionary) could be added behaviors.

  • Hmm, that's a bit of an oversight. You can't add No Save to those objects right now (or Persist). I'll see if I can come up with something to fix that.

  • Please don't add no save option at their properties table.

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