[ SOLVED ] skeleton_bone_state_get() not working?

rIKmAN

Member
I have a simple Spine animation which basically scales a bone from 1.0 to 1.1 on both axis a few times over the course of 20ish frames of animation.

The bone being scaled is called "centre", and is directly under the default "root" bone, and the animation plays fine in both Spine and inside GM when using "skeleton_animation_set".

The problem is that I simply cannot seem to get any data from the Spine skeleton.

Here is my code, all placed within the object which the Spine sprite is attached to:

Create Event
Code:
// setup map
centreMap = ds_map_create()

// set start animation to 'selected' which scales from 'centre' bone from 1.0 to 1.1 repeatedly
skeleton_animation_set("selected")
Animation Update Event (have also tried this in Step Event)
Code:
// get current bone data
skeleton_bone_state_get("centre", centreMap)

// assign values from map
centreWX = ds_map_find_value(centreMap,"worldX")
centreWY = ds_map_find_value(centreMap,"worldY")

centreSX = ds_map_find_value(centreMap,"xscale")
centreSY = ds_map_find_value(centreMap,"yscale")

centreWSX = ds_map_find_value(centreMap,"worldScaleX")
centreWSY = ds_map_find_value(centreMap,"worldScaleY")
Draw GUI Event (in case the standard Draw Event was causing problems somehow)
Code:
// draw names
draw_set_halign(fa_right)
draw_text(x, y + 100, "spr_x: ")
draw_text(x, y + 120, "spr_y: ")
draw_text(x, y + 140, "centreWX: ")
draw_text(x, y + 160, "centreWX: ")
draw_text(x, y + 180, "centreSX: ")
draw_text(x, y + 200, "centreSX: ")
draw_text(x, y + 220, "centreWSX: ")
draw_text(x, y + 240, "centreWSX: ")

// draw values
draw_set_halign(fa_left)
draw_text(x + 10, y + 100, string(x))
draw_text(x + 10, y + 120, string(y))
draw_text(x + 10, y + 140, string(centreWX))
draw_text(x + 10, y + 160, string(centreWY))
draw_text(x + 10, y + 180, string(centreSX))
draw_text(x + 10, y + 200, string(centreSY))
draw_text(x + 10, y + 220, string(centreWSX))
draw_text(x + 10, y + 240, string(centreWSY))
As I said the animation plays fine, I can see it scaling on screen and playing the animation, but the problem is that the values don't seem to get updated past the first frame of the animation.

Here is a pic of what I'm seeing - imagine the square pulsating bigger/smaller between scale values 1.0-1.1, and the text doesn't change at all from that shown in the picture.



I've checked Spine and the scale hits 1.01 on the second frame of the animation, so it does update at least once to get past frame 1 (which is scale 1.0), but then doesn't seem to update any further even though the animation is playing, and I'm continuously reading the data into a map (skeleton_bone_state_get) and updating the variables I 'draw_text' every frame in the Animation Update event.

Has anyone got any idea what's going on or what I'm doing wrong?

I'm using GM v1.4.1763.

EDIT:
Just rolled back to v1.4.1757 and it's the same, so I'm thinking I'm doing something wrong because something this basic in ther Spine support being broken would have surely been reported and fixed....wouldn't it?
 
Last edited:

rIKmAN

Member
Clear your ds_map each step after you get your data.
Dude thank you! :)

I was using ds_list_copy() in an unrelated program the other night and the docs say if the list being copied to already has data it will be auto-cleared before copying.

I guess I had that in my head and assumed that the new read would overwrite or clear the map itself and update with the new data.

I'll mark this as solved - thanks again!
 

obscene

Member
Yeah I thought the same thing actually... but yeah you have to ... plus you didn't realize it but you had a memory leak from that too.
 

obscene

Member
From not clearing it, so each step you are adding more data. This is why when you werent clearing it before your animation never updated past the first frame.... the new info was being wrote to subsequent places in the map.
 

rIKmAN

Member
From not clearing it, so each step you are adding more data. This is why when you werent clearing it before your animation never updated past the first frame.... the new info was being wrote to subsequent places in the map.
I did read something about that...somewhere...been doing a lot of GM learning the last few weeks, and was going to look into it and run some tests but got sidetracked as you do when coding.

The docs say "There is also no way to hold two keys that are the same" - which I assumed meant that as I was reading the same keys repeatedly from the Spine skeleton, they would either overwrite the existing key, or be discarded as a duplicate automatically.

Obviously I misunderstood, so thanks for the heads up, good to know for the future.
 

obscene

Member
No I'm with you ... I thought the exact same thing from the docs. It makes no sense.... I think it's a bug.
 
Top