I'm still somewhat stuck in my journey on to make a construct plugin.
They plugin I want to make will be used to group any bodies (rigorously of the same type) that are interacting and make a single group out of them, so they could move together and so on...
After researching the currently plugins available, I think ObjectPairer comes closer on the kind of functionality I want to produce. There is also the Array plugin, which, I (Hope) I could learn how to get the properties of the other bodies using the SDK. But none of them has their source code available in the construct-source zip file.
Stripping my problem of all the details, I need a way to, using the SDK, get all the bodies of the same type that are interacting and make an array out of them, so I could update all their positions color, etc at the same time.
Could you guys please direct me? Or help me reach dave or the author of the Array plugin?
Thanks you very much and sorry for the bother.
Just curious, is there a specific formation you wish to use?
about the formation, I want to create huge terrain and ice blocks.
For example, whenever the player destroys the terrain/ice cube, the one's falling will snap to the others in rest and their images will change in result, as to always look like a huge terrain/iceberg block. These blocks can be moved, but only as a 'single' entity.
That doesn't sound too bad to replicate in events even without those plugs.
The snapping together would be the easy part, but moving as a single object would be a bit involved, especially if you want to preserve angle.
If you can set that up in events, there's a good chance the devs could point you in the right direction as to how to do it in a plug.
For example Lucids "S" plug has an expression to help make on the fly image points.
the problem I'm facing using the events is that I can't get the other body properties properly when the collision involves objects of the same type. I can't tell which one is body A or body B in the collision, therefore I wanted to make the plugin. This happens at least in my construct's version (0.9.x).
So I've tried lots of things using the events, but failed. Like trying to use families to distinguish every body in the collision and so on. If i could get the position of all objects of the same type that are on stage, that would be pretty easy.
You could try all of the same object with different frames.
what about using the Array and/or HashTable plugins?
I don't see the point, each instance can hold several variables.
Then use a for each object.
If I could create an array of sprite Objects (not sprite objects carrying an array), I think I could check the state of all of them the way I wanna do...
U can create an array of objects with the s plugin
Here's a simplified example of what I was thinking.
Develop games in your browser. Powerful, performant & highly capable.
an example of how this could work if you're still interested in making the plugin is this
in main.h make a vector
then have an action that takes an object parameter
and just do
myobjects.push_back(params.GetObjectParamFirstInstance(pRuntime));//GetObjectParam is for CRunObjType* which is a type pointer as opposed to a specific object pointer
and within construct do a for each object in the subevent after doing whatever picking condition you need to add each one by one. it's also possible to automatically get the entire list of picked objects automatically, but I can't think of how off the top of my head, and don't have the time automatically to go look up how. if you search my posts in this [construct engineering] forum, and go to the oldest posts, you can find alot of useful replies from ashley when I was first starting out asking ten billion questions.
after you had the objects loaded in the myobjects vector you could access them by index, if you wanted to move them all into a row for instance you could do something like
myobjects[j]->info.x=j*myobjects[j]->info.w;//w:width...the .info structure has pretty much anything useful you'd want to do with objects, and most is self-explanatory
if you want to use the plugin generally, and want it to automatically get rid of objects destroyed in construct so you don't get a crash accessing invalid pointers
in runtime.cpp in OnFrame2()
you could do either
if(myobjects[j]->info.destroying)//checking this in onframe2 is the last time this pointer will be valid, if the object is destroyed the pointer will be invalid the next tick
which would erase that index in the vector, and move all the rest back to fill the gap
or you could do
this would leave that index there, but with no object, so you could do a line of object like before, for instance, and have a gap in the line, instead of having the other objects fill that gap, you would have to modify it to check for the existence of a sprite, again to avoid crashes for accessing invalid pointers like so:
if(myobjects[j])//add this to check if the pointer is nonzero...if not, you "erased" it