Home / Topic / How to use custom file to show Spine animation

How to use custom file to show Spine animation

Home Kwiksher Forums Kwik4 How to use custom file to show Spine animation

Viewing 2 posts - 1 through 2 (of 2 total)
  • Yamamoto
    Keymaster
    #84809

    custom file to show a spine aniamtion

    page1.psd has a layer group – spinebody
    create spine aniamtion with png files which are generated with LayersToPNG script of Spine

    In Kwik, publish spinebody layer group and other images such as background etc
    It produces build4/components/page01/spineboy_image_.lua
    Create a custome file – build4/custom/components/page01/spineboy_image_.lua
    Modify the custom file with the function below and re-publish.

    Using this local function instead of display.newImageRect will show up a spine animation for spineboy. Notice spinebody.json and spinebody.atlas are used

    
    local spine       = require "spine-corona.spine"
    
    local function newImageRect(name, ext, width, height)
      local json            = spine.SkeletonJson.new()
      local skeletonData    = json:readSkeletonDataFile(_K.spriteDir.."spineboy.json")
      local skeleton        = spine.Skeleton.new(skeletonData)
      local spritesskeleton = spine.GetAtlasSprites(_K.spriteDir.. "./spineboy.atlas" )
    
      spritesskeleton.ATLAS_HELPER_setup(skeleton)
      skeleton.group.x = display.contentWidth/2
      skeleton.group.y = display.contentHeight/2
      skeleton.flipX = false
      skeleton.flipY = false
      skeleton.debug = true -- Omit or set to false to not draw debug lines on top of the images.
      skeleton.debugAabb = true
      skeleton:setToSetupPose()
    
      local stateData = spine.AnimationStateData.new(skeletonData)
      local state = spine.AnimationState.new(stateData)
      state:setAnimationByName(0, "animation", true, 0)
      state.lastTime = 0
      state.skeleton = skeleton
    
      function state:onComplete(i, count)
        Runtime:removeEventListener("enterFrame", self)
      end
    
      function state:enterFrame (event)
          local currentTime = event.time / 1000
          local delta = currentTime - self.lastTime
          self.lastTime = currentTime
          self:update(delta)
          self:apply(self.skeleton)
          self.skeleton:updateWorldTransform()
      end
      Runtime:addEventListener("enterFrame", state)
      return skeleton.group
    end
    

    Yamamoto
    Keymaster
    #84811

    spine lua files for Corona SDK works with Spine > Settings > Version 2.1.27.

    Mesh with bone works with bone animation but mesh without bone not work by changing mesh vertices. It is spine lua problem.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Privacy Preference Center

Strictly Necessary

these coolies are for WP-SpamShield, gdpr-wp, woocommerce, paypal

PHPSESSID, SJECT16, JCS_INENREF, JCS_INENTIM, gdpr, woocommerce_cart_hash, woocommerce_items_in_cart, woocommerce_recently_viewed, wordpress_, wordpress_logged_in_, wordpress_sec_, wordpress_test_cookie, wp_woocommerce_session_, AKDC, akavpau_ppsd

Functionality

WordPress cookie created when auto-saving a post in the editor.

wp-saving-post, wp-settings-, wp-settings-time-

Performance

google analytic

__utma,__utmb,__utmc,__utmz,_ga,_gid,_gat

Advertising