I ask for help.
I added the Spine animation ( version 3.8 ) to my game made on the Corona SDK.
I have 2 questions:

1. To work correctly with the Composer library, I added my display group as the 2nd argument when calling the function:

local skeleton = spine.Skeleton.new(skeletonData,mainGroup)

can this be done?

2. I drew a bounding box around my character in the Spine editor

bb in spine.jpg

But for some reason in runtime I have 2 bounding boxes displayed on and under the character.

In the code, I add a bounding box like this:

torso = skeleton:findBone("submarine")
local vertices = skeleton:getAttachment ("bb_submarine", "bb_submarine").vertices
polygon = display.newPolygon(mainGroup, 0, 0, vertices)
polygon:setFillColor(0.5, 0)
polygon.strokeWidth = 5
polygon:setStrokeColor(0, 1, 1, 1)
polygon.yScale = -1
physics.addBody(polygon, "dynamic")
--Update bounding box's position
skeleton.x = polygon.x
skeleton.y = polygon.y
polygon.rotation = - torso.rotation

Why do I get 2 bounding boxes?


I will be happy for any help!
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
  • Beiträge: 2


1. I'm afraid I'm not familiar with the Composer library. Can you give me a link? In general, the second argument should work as intended, the skeleton will display underneath the group you provided.

2. It's hard to say why you see two polygons instead of one based on the code you provided. If the code is only executed once, then Corona should only display a single polygon. Are you sure it's only executed once?

  • Beiträge: 2302


1. Composer library description : https://docs.coronalabs.com/api/library/composer/index.html
2. I do not see in my code that the polygon is created twice. I wrote the code following the example of the test.lua file, which is located in your library on GitHub. I used it with the Composer library.
I will check my code again and write to you later.


I figured it out! The problem was in my code.
I put the polygon creation in function loadskeleton (...) and called it twice with different animations:

table.insert(skeletons, loadSkeleton("anim/tito/skeleton.atlas", "anim/tito/skeleton.json", 0, 0, 1, "go_front"))
table.insert(skeletons, loadSkeleton("anim/tito/skeleton.atlas", "anim/tito/skeleton.json", 340, 300, 1, "go_up"))

Thanks for the quick response
  • Beiträge: 2

Zurück zu Runtimes