Home / Topic / how to use texture packer for layerX_image.lua

how to use texture packer for layerX_image.lua

Home Kwiksher Forums Kwik4 how to use texture packer for layerX_image.lua

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

    this is experimental to modify the default template file – tmplt/components/pageXXX/layerX_image.lua

    use texture packer to compile p1_xxx.png files in build4/assets/images except background file.
    then export the lua and image sheet file to build4/assets/sprites


    if you have @2.png files in build4/assets/images, you need to create the image sheet with @2


    add the following function to tmplt/components/pageXXX/layerX_image.lua
    and substitute display.newImageRect for the local function ‘newImageRect’

    please notice that background layer needs to be named as ‘background’

    local info     = require ("assets.sprites.".."page{{docNum}}")
    local sheet    = graphics.newImageSheet ( _K.spriteDir.."page{{docNum}}.png", info:getSheet() )
    local sequence = {start=1, count= #info:getSheet().frames }
    function newImageRect(name, ext, width, height)
      local image
      if string.find(name, "background") == nil then
          image = display.newSprite(sheet, sequence)
          image.name = name
          image:setFrame (info:getFrameIndex (name))
          image.width, image.height = width, height
           image = display.newImageRect(_K.imgDir..name.."."..ext, width, height)
      return image

    then use the local function above instead of display.newImageRect

    function _M:localPos(UI)
      local sceneGroup  = UI.scene.view
      local layer       = UI.layer
            layer.{{myLName}} = newImageRect("p{{docNum}}_{{bn}}", "{{fExt}}", {{elW}}, {{elH}} )
            layer.{{myLName}}.imagePath = _K.imgDir.. "p{{docNum}}_{{bn}}.{{fExt}}"
            layer.{{myLName}} = newImageRect("{{bn}}", "{{fExt}}", {{elW}}, {{elH}} )
            layer.{{myLName}}.imagePath = _K.imgDir.. "{{bn}}.{{fExt}}"

    this method can be applied to spine http://esotericsoftware.com/ as well. I will try soon.

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


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

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


google analytic