Working with the SDK – Object Properties

Working the C2 SDK is not elegant. In fact I would say that the C2 engine was not designed for other developers. There is a lack of documentation and overall a lack of an SDK engine. Instead most of the work with C2 engine is through a small set of callbacks and properties. Often Scirra(Ashley) encourages that Plugins and behaviors have little interaction with others of similar type. Such as no Plugin to Plugin interaction and no Behavior to Plugin interaction. Also no Plugin to Behavior interaction, but Behavior to Plugin interaction is encouraged… whew.

however making anything advanced requires either an SDK or just plain ignoring all this direction. Developers such as RexRainbow and R0j0hound are two in the community that do so regularly. With a lack of documentation I have been repeating a simple code that logs the properties of an Object, but this is becoming tedious so I’m going to post the property names in this post. I’m also going to post a piece of code snippet that I use to grab another Plugin… not behavior.

Here is the snippet of code used to get the properties of an object.
console.log(“this from a [location]”);
for(name in this){ console.log(“property: ” + name ); }

WARNING:
The properties listed are from this and this.inst, however “this” may have a difference reference value.

C2 Get Plugin and the start of a C2 SDK

Put this in the top of the runtime.js, but under
assert2(cr, “cr namespace not created”);
assert2(cr.plugins_, “cr.plugins_ not created”);

// when using a function, we need to pass the memory instance
// in a js call function. so that the function assigns this as the right
// memory object
audioPlugin.acts.PlayByName.call(audioObject, 0, “foo”, 0, 1, “”);

Instance
Memory Runtime from
Plugin – this
Behavior – this.inst

This is from a WORLD only object. There are no positional, sizing or other such flags. So it’s surprising there is so much junk in the this. World seem that this is the level where behaviors would be attached. but there is reference to Tilemaps, even if tilemaps aren’t used. Sorry Ashley, but this seems poor design architect that everything including the kitchen sink get’s thrown in even when it’s not needed.

Examining the properties. This would look like a the prototype and not a run memory values… however it seems overall there is a lot of mixing. What really throws a strange wrench into this is that “this” when access from the initiator on Plugin.Proto.Instance a location where you create variables; this is not the same as the above Plugin memory run time.