Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Module for Quick implementation of Spine Animations
Started by hector7 Dec 09 2014 12:16 PM

42 replies to this topic
spine animation
[TOPIC CONTROLS]
Page 2 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

hector7

[GLOBAL: userInfoPane.html]
hector7
  • Enthusiast

  • 47 posts
  • Corona SDK

Thanks coronasdk771, yes good idea, let me put it in Github later tonight so everybody can contribute. I'll post the link here when it's ready

 

Regards

Hector



[TOPIC: post.html]
#27

Juf Jannie

[GLOBAL: userInfoPane.html]
Juf Jannie
  • Contributor

  • 327 posts
  • Corona SDK

Hi,

there seems to be an error in spineHelper.lua

line 511

currentAnimation = state:getCurrent(0).animation.name

 

It some how sometimes generates a runtime error.

When I run my app it runs it changes it a few times and then it pops up. Then works again a few times.

I have 3 animations in my sprites.

I changed it to "rest" state animation so it always has that as a default. And it seems to have solved it.

This only happens on the device not on the simulator.

I checked for capitalisation, but couldn't find any errors.

Is there somewhere I can look in my code or is this a spineHelper problem?



[TOPIC: post.html]
#28

coronasdk771

[GLOBAL: userInfoPane.html]
coronasdk771
  • Enthusiast

  • 44 posts
  • Corona SDK

@Hector

awsome!

 

@Juf Jannie

The line you mentioned is 520 in my case. I re-downloaded SpineHelper few days ago, maybe Hector made few tweaks here and there after you got SpineHelper. It might be worth re-downloading it.



[TOPIC: post.html]
#29

rlowenstein

[GLOBAL: userInfoPane.html]
rlowenstein
  • Observer

  • 23 posts
  • Corona SDK

Has anyone figured out how to listen for Spine "Events" within the context of using Hector's Spine Helper? Having some trouble figuring out exactly how to do this...

 

(and thanks for this module, Hector!!)



[TOPIC: post.html]
#30

rlowenstein

[GLOBAL: userInfoPane.html]
rlowenstein
  • Observer

  • 23 posts
  • Corona SDK

Has anyone figured out how to fix the runtime error on that "currentAnimation = state:getCurrent(0).animation.name" line in the module? For me it's on line 522 of the module.



[TOPIC: post.html]
#31

coronasdk771

[GLOBAL: userInfoPane.html]
coronasdk771
  • Enthusiast

  • 44 posts
  • Corona SDK

When I change animation with changeAnimation() I always get "Initial Animation is still running" in the console but never get runtime error. I also noticed that previous animation keeps playing for some time (2-3 secs) before transition to desired animation.

 

In the mean time I added remove() method because I didn't know how to get rid of loaded testures. Improvements are welcomed ;)

 

function SpineHelper:remove(...)
    self:stopAnimation()
    for k,v in pairs(self.skeleton.images) do
        if type(self.skeleton.images[k].removeSelf) == "function" then
            self.skeleton.images[k]:removeSelf()
        end
        self.skeleton.images[k] = nil
    end        
end

 

Also added one line in initialize()

        self.skeletonData = skeletonData
        self.skeleton = skeleton
        self.root = root
        self.stateData = stateData
        self.state = state
        sheet = nil    -- sheet is no longer needed

 

 

Has anyone figured out how to add touch listeners to whole animation object or specified bones? It can't get it working.



[TOPIC: post.html]
#32

hector7

[GLOBAL: userInfoPane.html]
hector7
  • Enthusiast

  • 47 posts
  • Corona SDK

Hey guys,

 

My apologies for not getting back sooner. I have two good news and a bad one:

 

1.- I have posted the SpineHelper library along with sample codes (including Photoshop, TexturePacker files) to GitHub so everyone can contribute and make it better. You can find it here: https://github.com/CoronaDevs/CoronaSDK-Spine-Helper

 

2.- I also created a FREE full video course (25 lessons) that teaches you the whole process from creating and designing a character in Photoshop,  creating the ImageSheet in TexturePacker, the animation of several characters in Spine, to the whole implementation in Corona, including adding interactivity to the characters created. You can find the tutorials here https://www.youtube.com/playlist?list=PLKhvt82d5sfCE6KkM1V6Bs46GG4HOguP1

 

3.- Finally the bad news.... I'm no longer maintaining the library as I've been busy with other stuff in my life, but I didn't want to leave without giving you access to the code in GitHub and the video tutorial. Feel free to make edits or create a totally new version of my code, I'm sure you can take it to a new level

 

Regards

Hector



[TOPIC: post.html]
#33

coronasdk771

[GLOBAL: userInfoPane.html]
coronasdk771
  • Enthusiast

  • 44 posts
  • Corona SDK

Hi Hector, thanks for putting source on GitHub and videos. Could you please add license info for SpineHelper? Without it it may be blocking use of SpineHelper in some cases. Hope the community will pick up development, will you accept any pull requests or should we use our forks?



[TOPIC: post.html]
#34

hector7

[GLOBAL: userInfoPane.html]
hector7
  • Enthusiast

  • 47 posts
  • Corona SDK

Hi there!, sure I can add license info, any idea of what good wording I could use? I think it'd be better to let everybody to use their own fork that way they can work independently of mine

 

Regards,

Hector



[TOPIC: post.html]
#35

coronasdk771

[GLOBAL: userInfoPane.html]
coronasdk771
  • Enthusiast

  • 44 posts
  • Corona SDK

[TOPIC: post.html]
#36

rlowenstein

[GLOBAL: userInfoPane.html]
rlowenstein
  • Observer

  • 23 posts
  • Corona SDK

Does anyone know if it's possible to use multipacked image sheets out of texture packer with SpineHelper?



[TOPIC: post.html]
#37

coronasdk771

[GLOBAL: userInfoPane.html]
coronasdk771
  • Enthusiast

  • 44 posts
  • Corona SDK

No, SpineHelper assumes all sprites are on single sheet but you could easily hack that.



[TOPIC: post.html]
#38

rlowenstein

[GLOBAL: userInfoPane.html]
rlowenstein
  • Observer

  • 23 posts
  • Corona SDK

@coronasdk771 do you have any tips for implementing the multiple image sheet hack? I tried by adding an additional set of arguments to the config table for a second sheet (so like imageSheetName2, texturePackerLuaFile2, info2, sheet2),  and then adding a new skeleton:createImage function (spineHelper line 142) to deal with the second sheet, but couldn't get it to work. Any advice/guidance on this would be really appreciated. Thanks!!



[TOPIC: post.html]
#39

rlowenstein

[GLOBAL: userInfoPane.html]
rlowenstein
  • Observer

  • 23 posts
  • Corona SDK

In case anyone else needs to use multiple image sheets out of texturePacker with SpineHelper, here's what finally seems to be working for me:

 

Step 1: I added in additional imageSheetName and texturePackerLua to the config table:

 -------------------------------------------------
 --1.- Initial Configuration of Spine Animation
 -------------------------------------------------
      
local config = config or {}
      
local spineJson = config.spineJson -- JSON file produced by Spine (*** REQUIRED **)

local imageSheetName = config.imageSheetName --PNG image file produced by Texture Packer (*** REQUIRED **)
local imageSheetName2 = config.imageSheetName2 -->> ADDED FOR ADDITIONAL IMAGE SHEET


local texturePackerLuaFile = config.texturePackerLuaFile --Lua file produced by Texture Packer (*** REQUIRED **)
local texturePackerLuaFile2 = config.texturePackerLuaFile2 -->> ADDED FOR ADDITIONAL IMAGE SHEET

Step2: Then I added in the additional info, sheet, and sequence data for the additional sheets:

 ---------------------------------------------
 --2.- Load Texture Packer Image Sheet
 ---------------------------------------------        
 local info = require (texturePackerLuaFile)
 local info2 = require (texturePackerLuaFile2) -->> ADDED 

 local sheet1 = graphics.newImageSheet ( imageSheetName, info:getSheet() )
 local sheet2 = graphics.newImageSheet ( imageSheetName2, info2:getSheet() ) -->> ADDED 

 local sequence1 = { start=1, count= #info:getSheet().frames }  
 local sequence2 = { start=1, count= #info2:getSheet().frames } -->> ADDED

And finally I modified the skeleton:createImage function to look for the attachment name in the second sheet if the name is nil in the first sheet:

    -------------------------------------------
    --3.1 Draw Skeleton with its images
    -------------------------------------------

      function skeleton:createImage(attachment)

            local image

            -- check to see if the requested attachment is in sheet 1
            if ( info:getFrameIndex ( attachment.name ) ) ~= nil then 

              image = display.newSprite(sheet1, sequence1)
              image.name = attachment.name
              image:setFrame (info:getFrameIndex (attachment.name))
              image.width, image.height = attachment.width, attachment.height

            end 

            -- check to see if the requested attachment is in sheet 2
            if ( info2:getFrameIndex ( attachment.name ) ) ~= nil then

              image = display.newSprite(sheet2, sequence2)
              image.name = attachment.name
              image:setFrame (info2:getFrameIndex (attachment.name))
              image.width, image.height = attachment.width, attachment.height

            end 

            return image 
      end

Thought I'd share just in case anyone else spends 2 days totally stumped like me :)



[TOPIC: post.html]
#40

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 154 posts
  • Corona SDK

Amazing job with the spineHelper Hector  :lol: Million thanks for sharing it and making the video tutorials  :)

 

Hey guys,

 

My apologies for not getting back sooner. I have two good news and a bad one:

 

1.- I have posted the SpineHelper library along with sample codes (including Photoshop, TexturePacker files) to GitHub so everyone can contribute and make it better. You can find it here: https://github.com/CoronaDevs/CoronaSDK-Spine-Helper

 

2.- I also created a FREE full video course (25 lessons) that teaches you the whole process from creating and designing a character in Photoshop,  creating the ImageSheet in TexturePacker, the animation of several characters in Spine, to the whole implementation in Corona, including adding interactivity to the characters created. You can find the tutorials here https://www.youtube.com/playlist?list=PLKhvt82d5sfCE6KkM1V6Bs46GG4HOguP1

 

3.- Finally the bad news.... I'm no longer maintaining the library as I've been busy with other stuff in my life, but I didn't want to leave without giving you access to the code in GitHub and the video tutorial. Feel free to make edits or create a totally new version of my code, I'm sure you can take it to a new level

 

Regards

Hector



[TOPIC: post.html]
#41

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 154 posts
  • Corona SDK

Oh! I can´t figure this out :(

I get an error:

spine-lua/AttachmentLoader.lua:51: attempt to concatenate local 'type' (a nil value)

 

/Users/Admin/Dropbox/CORONA/prosjekt/testSpine/spine-lua/AttachmentLoader.lua:51: in function 'newAttachment'

/Users/Admin/Dropbox/CORONA/prosjekt/testSpine/spine-lua/SkeletonJson.lua:175: in function 'readAttachment'

/Users/Admin/Dropbox/CORONA/prosjekt/testSpine/spine-lua/SkeletonJson.lua:136: in function </Users/Admin/Dropbox/CORONA/prosjekt/testSpine/spine-lua/SkeletonJson.lua:67>

(tail call): ?

/Users/Admin/Dropbox/CORONA/prosjekt/testSpine/SpineHelper.lua:130: in function 'initialize'

/Users/Admin/Dropbox/CORONA/prosjekt/testSpine/SpineHelper.lua:75: in function 'new'

 

I figure it has to be with my skeleton-file?! I tried using Hectors tutorial files and they work fine  :wacko: I don´t understand. I do everything exactly as Hector says.



[TOPIC: post.html]
#42

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 154 posts
  • Corona SDK

Ok! I just deleted line 51 in spine-lua/AttachementLoader.lua and now it works fine ;)

This line:

--error("Unknown attachment type: " .. type .. " (" .. name .. ")")



[TOPIC: post.html]
#43

undecode

[GLOBAL: userInfoPane.html]
undecode
  • Contributor

  • 198 posts
  • Corona SDK

I'm late to the party, but I wanted to thank you Hector for this awsome helper!

 

I'm starting to work on my animations on Spine and i'm using your module, I saw some people asked before... but how do you manage events? For example when I want another animation to start playing when the previous one ended (for example after a jump, always play run, or even better run for a bit then walk)?

 

I know you can do it with "state.onComplete" in the Spine runtimes, but It doesn't look like you can manipulate them with your helper.

Anyway, the code is out there for us to modify so if i manage to change it I'll post an updated module.

 

Thanks again!




[topic_controls]
Page 2 of 2 1 2
 
[/topic_controls]