Released spineSlotExt - An extension for GMS1+GMS2 to allow runtime colouring of slots on Spine skeletons...

rIKmAN

Member
spineSlotExt v1.0

SpineSlotExt is an extension for GameMaker Studio 2 and GameMaker: Studio 1.4 that provides functions to allow the runtime manipulation of individual slot colour and slot alpha on Spine skeletons

Instead of having to waste time and resources creating multiple versions of the same sprites and wasting space on the single texture page Spine sprites can use, you can now create a single set of sprites and change their colour and alpha at any time during runtime using the provided functions.

Collision detection of individual slots is also simplified, and you can detect pixel perfect collisions with any bounding box attachments setup inside Spine using only a single function call.

The extension contains no scripts and all functions will appear as native GML functions keeping your projects clean, and it is compatible with all export targets that support the use of Spine skeletons in GameMaker: Studio and GameMaker Studio 2.




 
M

maranpis

Guest
Bought it today.You can check a paid from China :D

I tried for one week to understand how to do the collisions (get bounds etc.) with spine and gamemaker, read all the forums about this topic,read the documentation, tried by myself but i feel I'm wasting my time so I hope your runtime can help to keep going. Thanks rIKmAN i think maybe I will contact you soon with doubts if you don't mind ;)

Please YOYO fix spine in GAMEMAKER 2.
 

rIKmAN

Member
Bought it today.You can check a paid from China :D

I tried for one week to understand how to do the collisions (get bounds etc.) with spine and gamemaker, read all the forums about this topic,read the documentation, tried by myself but i feel I'm wasting my time so I hope your runtime can help to keep going. Thanks rIKmAN i think maybe I will contact you soon with doubts if you don't mind ;)

Please YOYO fix spine in GAMEMAKER 2.
Detecting collisions is as simple as setting up your bounding boxes correctly in Spine and then calling 1 function to return all collisions.

Hopefully the included manual and fully commented example project will explain everything you need to get things working in your project, each of the 11 rooms shows the various functions and usage of them and they gradually get more advanced - so if you take a look through them from beginning to end you should be good.

Of course if you have any questions or need any help then of course feel free to contact me.

Thanks for your purchase, I appreciate it! :)
 
M

maranpis

Guest
Detecting collisions is as simple as setting up your bounding boxes correctly in Spine and then calling 1 function to return all collisions.

Thanks for your purchase, I appreciate it! :)
You are welcome, I appreciate your work, you are making Spine a better tool in GM.

Do you mind to write down just a simple code to see how to call collisions? I added the bounding box, in this case, to the enemy's sword but i don't know how to call it.

I don't know if skeleton_get_bounds is what i need.but the example code is confusing to me:

var num = skeleton_get_num_bounds();
var yy = 60;
for(var i = 0; i < num; i++ ; )
{
var b_info = skeleton_get_bounds(i);
if b_info[0] > 0
{
var data = b_info[1] + ":";
for(var j = 0; j < b_info[0]; j++ ; )
{
data += " (" + string(b_info[(j * 2) + 2]) + ", " + string(b_info[(j * 2) + 2 + 1]) + ")";
}
draw_text(20, yy, data);
yy += 20;
}
}

Thanks a lot!
 

rIKmAN

Member
Looks so cool and useful! Good work ^^
Thanks, I appreciate it! :)

You are welcome, I appreciate your work, you are making Spine a better tool in GM.

Do you mind to write down just a simple code to see how to call collisions? I added the bounding box, in this case, to the enemy's sword but i don't know how to call it.

I don't know if skeleton_get_bounds is what i need.but the example code is confusing to me:

var num = skeleton_get_num_bounds();
var yy = 60;
for(var i = 0; i < num; i++ ; )
{
var b_info = skeleton_get_bounds(i);
if b_info[0] > 0
{
var data = b_info[1] + ":";
for(var j = 0; j < b_info[0]; j++ ; )
{
data += " (" + string(b_info[(j * 2) + 2]) + ", " + string(b_info[(j * 2) + 2 + 1]) + ")";
}
draw_text(20, yy, data);
yy += 20;
}
}

Thanks a lot!
None of that code is needed at all - the extension takes care of everything and provides a simple function for you to use which will return a list of all slots that are colliding with a given x/y coordinate:

sse_skeleton_get_slot_at_point(x, y)


x/y could be for example the mouse cursor, a bullet or the tip of your characters sword etc.
You could do something like deal different amounts of damage depending on which part of a weapon collides with a slot - the tip of a sword or whip dealing the most damage, the base the least - that sort of thing.

Then you iterate the returned list with a for loop and do whatever you want with the data.

For example: if it was an end of level boss you could change the attachment of that individual slot to a damaged sprite, allowing you to have specific slots that you hit show damage (head, arms, shields, tentacles, eyes etc) and tie that into gameplay where different slots take different damage amounts, or where you had to damage specific parts of a skeleton to kill them (that only appear in an animation that is triggered after damaging 8 slots on the original animation)

Imagine having to damage 8 eyeballs on a monster before you triggered an animation where he screamed and revealed a new "tongue" slot in his mouth that you have to destroy to actually "kill" him....

I'm going a bit off topic now, but as you can see you can get quite creative with it!

However in Example_04 I just colour each slot that collides with
mouse_x and mouse_y red using the function: sse_skeleton_set_slot_color(slot_name, 255, 0, 0)

Example_04 doesn't use a coloured skeleton, but it will basically look like this:


Did you look at the example project?
Each example is pretty thoroughly commented and explains each function and how / why it's used.

If you open the included project in your version of GMS, you will see it contains 11 rooms, and under "Objects" in the resource tree is a matching object for each of these example rooms.


If you then open the corresponding example object for the example room you want to study in the resource tree (Example_04 in this case) you will see the fully commented code which is used to make that particular thing happen (loading, colouring, collisions, alpha, skins, attachments etc).

As I said previously I would advise starting with Example_00 and working your way through them in order, as the examples build on the previous ones and add new functions and get a little more complex as they go on.

Hopefully that helps, but if you are still struggling after looking at the examples and the documentation then please let me know and I'll be happy to chat to you on Discord on similar to get you up and running. :)
 
Last edited:
M

maranpis

Guest
Thanks, I appreciate it! :)



None of that code is needed at all - the extension takes care of everything and provides a simple function for you to use which will return a list of all slots that are colliding with a given x/y coordinate:

sse_skeleton_get_slot_at_point(x, y)


x/y could be for example the mouse cursor, a bullet or the tip of your characters sword etc.
You could do something like deal different amounts of damage depending on which part of a weapon collides with a slot - the tip of a sword or whip dealing the most damage, the base the least - that sort of thing.

Then you iterate the returned list with a for loop and do whatever you want with the data.

For example: if it was an end of level boss you could change the attachment of that individual slot to a damaged sprite, allowing you to have specific slots that you hit show damage (head, arms, shields, tentacles, eyes etc) and tie that into gameplay where different slots take different damage amounts, or where you had to damage specific parts of a skeleton to kill them (that only appear in an animation that is triggered after damaging 8 slots on the original animation)

Imagine having to damage 8 eyeballs on a monster before you triggered an animation where he screamed and revealed a new "tongue" slot in his mouth that you have to destroy to actually "kill" him....

I'm going a bit off topic now, but as you can see you can get quite creative with it!

However in Example_04 I just colour each slot that collides with
mouse_x and mouse_y red using the function: sse_skeleton_set_slot_color(slot_name, 255, 0, 0)

Example_04 doesn't use a coloured skeleton, but it will basically look like this:


Did you look at the example project?
Each example is pretty thoroughly commented and explains each function and how / why it's used.

If you open the included project in your version of GMS, you will see it contains 11 rooms, and under "Objects" in the resource tree is a matching object for each of these example rooms.


If you then open the corresponding example object for the example room you want to study in the resource tree (Example_04 in this case) you will see the fully commented code which is used to make that particular thing happen (loading, colouring, collisions, alpha, skins, attachments etc).

As I said previously I would advise starting with Example_00 and working your way through them in order, as the examples build on the previous ones and add new functions and get a little more complex as they go on.

Hopefully that helps, but if you are still struggling after looking at the examples and the documentation then please let me know and I'll be happy to chat to you on Discord on similar to get you up and running. :)
thank for your help rIKmAN i tried different things and I'm getting closer to the solution. Here I posted my problem with details:

https://forum.yoyogames.com/index.p...-working-as-expected-images-and-videos.48954/

Do you think i can solve this problem with sse_skeleton_get_slot_at_point(x, y)?

thanks again for your help :)
 

rIKmAN

Member
thank for your help rIKmAN i tried different things and I'm getting closer to the solution. Here I posted my problem with details:

https://forum.yoyogames.com/index.p...-working-as-expected-images-and-videos.48954/

Do you think i can solve this problem with sse_skeleton_get_slot_at_point(x, y)?

thanks again for your help :)
Yes that would be possible with the extension.
Just add a bone on the end of the enemies sword inside Spine, which means it will adjust automatically and keep it's position throughout your animations.
Then pass the x/y of that bone into the sse_skeleton_get_slot_at_point() function each to return a list of all slots that were detected at that position.

Looking at your pictures in that thread of your bounding boxes though, I don't think you require such precise detection and just using the standard collisions should be enough.

However I'm not sure why your regular GMS collisions aren't working as I would have to see your code, but I would assume there is some issue with your setup or code which is causing the problems you are having.

If you wanted to jump on Discord or host your project somewhere and PM me with the details I'd be happy to take a look. :)
 
Last edited:
M

maranpis

Guest
Yes that would be possible with the extension.
Just add a bone on the end of the enemies sword inside Spine, which means it will adjust automatically and keep it's position throughout your animations.
Then pass the x/y of that bone into the sse_skeleton_get_slot_at_point() function each to return a list of all slots that were detected at that position.

Looking at your pictures in that thread of your bounding boxes though, I don't think you require such precise detection and just using the standard collisions should be enough.

However I'm not sure why your regular GMS collisions aren't working as I would have to see your code, but I would assume there is some issue with your setup or code which is causing the problems you are having.

If you wanted to jump on Discord or host your project somewhere and PM me with the details I'd be happy to take a look. :)
Thanks rIKmAN! that's a great idea I will keep trying a little bit to find a way if I don't find any solution i will host the project. Appreciatte your help ;)

I will keep thinking about how to do it...:cool:
 

rIKmAN

Member
Thanks rIKmAN! that's a great idea I will keep trying a little bit to find a way if I don't find any solution i will host the project. Appreciatte your help ;)

I will keep thinking about how to do it...:cool:
I've just quickly knocked up a very basic project doing what I described above, and I've PM'd you a link to a file which includes the commented GMS2 project and both Spine projects so you can see how both were setup.

You seem to be struggling a little to get your head around things and are maybe new to using Spine and GMS2 so I just used standard collisions in the example, but the same principle applies to using the extension once you get the hang of the basics.

It looks like this, hope it helps!

 
M

maranpis

Guest
I've just quickly knocked up a very basic project doing what I described above, and I've PM'd you a link to a file which includes the commented GMS2 project and both Spine projects so you can see how both were setup.

You seem to be struggling a little to get your head around things and are maybe new to using Spine and GMS2 so I just used standard collisions in the example, but the same principle applies to using the extension once you get the hang of the basics.

It looks like this, hope it helps!

Thanks! that's a very interesting project and it's what i'm lookign forward to. I'm going to analyze it! :cool:
 
M

Mischa Brandt

Guest
I'm a beginner in gml scripting, so i can ask stupid questions, i hope. :)
I have worked with some (gamemaker included ) collision examples and if i understood it correctly, it is necessary in many cases
to check an collision precise. (polygon collide with polygon) At least two rectangles makes sense to check.
No object has a dimension of 1 * 1 pixel. So your bounding check by x,y is insufficient?
I know, mouse position has x,y, but i have to compare for example a sword and the body, both with polygonal bounding boxes.
To check the "tip" of the sword is maybe not enough, cause the whole blade is sharp. ;)
Please, can you explain how a (more) precise collision would work with for example two spine models with body hitbox and sword.
Maybe i'm too stupid to see the advantage of your spine collision ex function.
I don't want to pay 20 bucks for an extension that makes no sense.
Another question is, how the performance is affected by your functions.
Can i handle theoretically more as a couple of spine files, or is gamemaker itself already the brake?
 

rIKmAN

Member
I'm a beginner in gml scripting, so i can ask stupid questions, i hope. :)
I have worked with some (gamemaker included ) collision examples and if i understood it correctly, it is necessary in many cases
to check an collision precise. (polygon collide with polygon) At least two rectangles makes sense to check.
No object has a dimension of 1 * 1 pixel. So your bounding check by x,y is insufficient?
I know, mouse position has x,y, but i have to compare for example a sword and the body, both with polygonal bounding boxes.
To check the "tip" of the sword is maybe not enough, cause the whole blade is sharp. ;)
Please, can you explain how a (more) precise collision would work with for example two spine models with body hitbox and sword.
Maybe i'm too stupid to see the advantage of your spine collision ex function.
I don't want to pay 20 bucks for an extension that makes no sense.
Another question is, how the performance is affected by your functions.
Can i handle theoretically more as a couple of spine files, or is gamemaker itself already the brake?
Questions aren't stupid, if you don't know the answer then you should ask!

My extension is not intended to completely replace the existing Spine collision functions in GMS - it's meant to work alongside them - so it provides a simple way to detect any slot(s) at a given x/y position as well as colour individual slots.

For detecting full bounding box to bounding box collisions you can use the existing skeleton functions - see the GMS manual for more information those functions.

If you wanted to change individual slot colour and do bounding box to bounding box collisions then you would use a combination of the normal GMS Spine functions and the functions from my extension - using one does not prevent you using the other, using them in tandem would be normal usage.

In terms of performance, there are compiled binaries on the itch.io page that you can download and test, the final room is a performance test you can use to see performance on your machine - bare in mind that performance will vary depending on the machine.

It should be noted that the skeleton in the example is overly complex, with ~20 individual bounding boxes defined with way more vertices (hundreds per skeletons) than what would be needed in a regular "game ready" skeleton.

In the final room of the compiled demo I mentioned, this skeleton (along with a couple of other Spine example skeletons) are placed 12 or so times, all with various effects and collisions enabled with the complex rig just for the purposes of testing performance - run them and see how they perform on your machine.

The extension uses shaders so if you have a low end machine or on board graphics then performance may be lower than on a better machine - as with any other game,

Hope that helps!
 
M

Mischa Brandt

Guest
Many thanks for the reply.
Maybe it could be a solution to use more x, y coordinates than a single one to simulate a reduced
area comparison. Maybe three, or five coordinate point.
Ok, i took a look at the demo. About 2000 FPS (I think 9 from 16 spines have collision detection on)
But as you said, it also depends on system.
 

rIKmAN

Member
Many thanks for the reply.
Maybe it could be a solution to use more x, y coordinates than a single one to simulate a reduced
area comparison. Maybe three, or five coordinate point.
Ok, i took a look at the demo. About 2000 FPS (I think 9 from 16 spines have collision detection on)
But as you said, it also depends on system.
You could place multiple bones on your skeleton and then use those as points to check within a defined area, but this is essentially what bounding boxes do already, but it's certainly possible if you wanted to do it that way - it would be just reinventing he wheel a little.

As I say the extension isn't meant to replace the existing functions, it's meant to be used in conjunction with them and provide functionality that the existing functions don't offer - ie. slot colouring / slot at x/y point.

The performance is pretty good yeah, and as I say it's very unlikely you would use a skeleton rig with as many bounding boxes and vertices to define those as I have on the demo skeleton, it would usually be way less as I went overboard defining hair, eyes, shirt buttons etc with many vertices where I could have used way less.

Feel free to try the demo binaries on a few different setups and see how both perform as there are differences between the GMS1 and GMS2 binaries also.
 
S

Sam (Deleted User)

Guest
You should've called the pelvis the crotch. Other than that, this looks really cool. I'll let you know if I ever end up using it. :)
 
Top