SDK2 Methods and Properties Parity

Not favoritedFavorited Favorited 0 favourites
  • 2 posts
From the Asset Store
Sync animations, animation frames, mirror state, sounds and anything else using these methods.
  • Hi Ashley, hope all is well. We just got finished porting the Spriter plugin to the new SDK, and there are a few of features from the original that are either missing or we couldn't locate in the docs as officially supported. We were able to find workarounds for all of them, but we would prefer to use the SDK as intended.

    1. Accessing a plugin's own animation frames at runtime

    We use SetHasAnimations(true) and load atlas PNGs into the plugin's animation frames at import time (editor-side). At runtime we need to enumerate those frames (legacy equivalent: GetObjectClass().GetAnimations()[0].GetFrames()), but we can't find a documented SDK v2 runtime API for this.

    With the edit-time access, we're manually adding the images we need to the project files which works, but means duplicating image data.

    2. Runtime methods/properties we couldn't find

    There are also several runtime operations where we're probing multiple method names, because we couldn't find the documented SDK v2 equivalent. This is working as a temporary workaround, but we'd like to replace these with the correct single API call. Apologies if they're already in the docs. I did a few searches and I couldn't find them:

    • Set origin/hotspot (SetOriginX/setOriginX, SetOriginY/setOriginY)

    • Invalidate bbox (SetBboxChanged/setBboxChanged)

    • Enable/disable collision (SetCollisionEnabled/setCollisionEnabled)

    • Enumerate instances (instances(), getAllInstances(), GetInstances())

    • Object type name (GetName(), .name)

    • Instance UID (GetUID(), getUID(), getUid(), .uid)

    • Container siblings (GetSiblings(), getSiblings())

    • Picked/paired instance (getPickedInstances(), getFirstPickedInstance(), getPairedInstance())

    • Sprite frame index (read) (_currentFrameIndex, currentFrameIndex, animationFrame)

    • Sprite frame index (write) (_DoChangeAnimFrame(), _changeAnimFrameIndex, animationFrame)

    • No-premultiply blend (renderer.SetNoPremultiplyAlphaBlend/setNoPremultiplyAlphaBlend)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • We use SetHasAnimations(true) and load atlas PNGs into the plugin's animation frames at import time (editor-side). At runtime we need to enumerate those frames (legacy equivalent: GetObjectClass().GetAnimations()[0].GetFrames()), but we can't find a documented SDK v2 runtime API for this.

    I don't believe animated plugins were ever officially documented and supported even in SDKv1. It's something I am very reluctant to expose, because animated plugins have a potentially very large API surface, and really it all only exists specifically for the Sprite object at the moment. We cannot implement it just for one plugin specifically, since if it's documented and accessible, then other plugins will start to depend on it, and then we end up dealing with all the potentially painful and limiting long-term maintenance implications of having external addons depending on Construct's animation subsystem.

    I can't recall the full history but I think it might be that Construct 3 only supported this to the same extent Construct 2 did solely for the benefit of the Spriter addon, as I think that is the only addon ever published that used the undocumented animation APIs. The intent of SDKv2 was to eliminate the possibility of accessing undocumented APIs precisely to avoid ending up with these kinds of accidental compatibility problems. I don't think there are any easy options here - to me the best thing to do is remove the use of animations from the Spriter plugin if you can, and find some other way to do what you need.

    • Set origin/hotspot (SetOriginX/setOriginX, SetOriginY/setOriginY)

    • Enable/disable collision (SetCollisionEnabled/setCollisionEnabled)

    All these are available on IWorldInstance.

    • Instance UID (GetUID(), getUID(), getUid(), .uid)

    • Container siblings (GetSiblings(), getSiblings())

    Available on IInstance. (Note the methods have changed to refer to "other container instances" rather than the term "siblings".)

    • Invalidate bbox (SetBboxChanged/setBboxChanged)

    This API is no longer needed with SDKv2.

    • Enumerate instances (instances(), getAllInstances(), GetInstances())

    • Object type name (GetName(), .name)

    • Picked/paired instance (getPickedInstances(), getFirstPickedInstance(), getPairedInstance())

    All available on IObjectClass.

    • Sprite frame index (read) (_currentFrameIndex, currentFrameIndex, animationFrame)

    • Sprite frame index (write) (_DoChangeAnimFrame(), _changeAnimFrameIndex, animationFrame)

    Available on ISpriteInstance via animationFrame property

    • No-premultiply blend (renderer.SetNoPremultiplyAlphaBlend/setNoPremultiplyAlphaBlend)

    Not sure why you need this as Construct always uses premultiplied alpha blending, which is necessary for correct rendering. These methods have actually been completely removed from the underlying engine as nothing ever needed them.

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