SpriteSheet

Hello, pls help

I build my SpriteSheet with TexturePackerGUI (Lite Version),

I want to animated my sprite object(ayam_anak1)

I have test it at SDK stimulator, there is no error when I output it

but

why nothing appear except the background

–====================================================================–
– this is the content of my build.settings file
–====================================================================–

settings =
{
        orientation =
        {
                default = “landscapeRight”,
                supported =
                {
                        “landscapeLeft”, “landscapeRight”
                },
        },
}

–====================================================================–
– this is the content of my config.lua file
–====================================================================–

application =
{
    content =
    {
        width = 320,
        height = 480,
        scale = “letterbox”,
        --fps = 60
    }
}

–====================================================================–
– this is the content of my main.lua file
–====================================================================–
 

display.setStatusBar( display.HiddenStatusBar )

local _w = display.contentWidth/2
local _h = display.contentHeight/2

background = display.newImage( “images/melur_kiambang/001/bg.png”, true )
background.x = _w
background.y = _h

local sheetData1 = require “images.melur_kiambang.001.ayam_anak1.ayam_anak1”
local data1 = sheetData1.getSpriteSheetData()

local imageSheet = graphics.newImageSheet( “images/melur_kiambang/001/ayam_anak1/ayam_anak1.png”, data1 )

local sequenceData =
{
        name=“walking”,
        start=3,
        count=6,
        time=2000,        – Optional. In ms.  If not supplied, then sprite is frame-based.
        loopCount = 0,    – Optional. Default is 0 (loop indefinitely)
        loopDirection = “forward”    – Optional. Values include: “forward”,“bounce”
}

local ayam_anak1 = display.newSprite( imageSheet, sequenceData )
ayam_anak1.x = _w
ayam_anak1.y = _h
ayam_anak1:play()

print( ayam_anak1.isPlaying )
print( ayam_anak1.frame )
print( ayam_anak1.numFrames )
print( ayam_anak1.sequence )
 

Not sure if setting the sequence is required, but try putting ayam_anak1:setSequence(“walking”) right before the call to play the sequence.

 Jay

Okay, setSequence shouldn’t be required, but in looking at your code I see you’re getting the image sheet data differently than I do (also using TexturePacker):

local sheetInfo = require("images.player") local myImageSheet = graphics.newImageSheet( "images/player.png", sheetInfo:getSheet() )

The sheetInfo:getSheet() is the part that’s really different.

 Jay

Hi Jay,

–====================================================================–
– this is the content of my main.lua file
–====================================================================–

display.setStatusBar( display.HiddenStatusBar )

local _w = display.contentWidth/2
local _h = display.contentHeight/2

background = display.newImage( “images/melur_kiambang/001/bg.png”, true )
background.x = _w
background.y = _h

local sheetData1 = require “images.melur_kiambang.001.ayam_anak1.ayam_anak1”
local imageSheet = graphics.newImageSheet( “images/melur_kiambang/001/ayam_anak1/ayam_anak1.png”, sheetData1:getSheet() )

local sequenceData =
{
        name=“walking”,
        start=3,
        count=6,
        time=2000,        – Optional. In ms.  If not supplied, then sprite is frame-based.
        loopCount = 0,    – Optional. Default is 0 (loop indefinitely)
        loopDirection = “forward”    – Optional. Values include: “forward”,“bounce”
}

local ayam_anak1 = display.newSprite( imageSheet, sequenceData )
ayam_anak1.x = _w
ayam_anak1.y = _h
ayam_anak1:play()

print( ayam_anak1.isPlaying )
print( ayam_anak1.frame )
print( ayam_anak1.numFrames )
print( ayam_anak1.sequence )

I try it (the text in bold) but got the error as below:

Runtime error

c:…\main.lua:23: attempt to call method ‘getSheet’ <a nil value>

stack traceback:

     [C]: in function ‘getSheet’

     c:…\main.lua:23: in main chunk

Hi Jay,

I try to attach the source as test.rar, but it say that the format that I try to attach don’t have the permit

If I want to include the source(main.lua, … ayam_anak1.tps) for your reference, pls let me know how to do it

thank

Hi Jay,

from what u mention at

local sheetInfo = require(“images.player”)
local myImageSheet = graphics.newImageSheet( “images/player.png”, sheetInfo:getSheet() )

then at http://www.coronalabs.com/blog/2013/04/18/guest-piece-an-introduction-to-texturepacker/

I find that I didn’t set the  Data Format  to **Corona SDK (image sheet) **at my images.melur_kiambang.001.ayam_anak1.ayam_anak1.lua file (the previous - I set it as Corona TM SDK)

Here is the corrected version of the main.lua file that I fix this morning until now

–====================================================================–

display.setStatusBar( display.HiddenStatusBar )

local _w = display.contentWidth/2

local _h = display.contentHeight/2

background = display.newImage( “images/melur_kiambang/001/bg.png”, true )

background.x = _w

background.y = _h

local sheetInfo = require( “images.melur_kiambang.001.ayam_anak1.ayam_anak1” )

local myImageSheet = graphics.newImageSheet( “images/melur_kiambang/001/ayam_anak1/ayam_anak1.png”, sheetInfo:getSheet() )

local sequenceData = {

    {

        name = “eat”, 

        frames = { 

            sheetInfo:getFrameIndex(“ayam_anak1_0007”),

            sheetInfo:getFrameIndex(“ayam_anak1_0008”),

            sheetInfo:getFrameIndex(“ayam_anak1_0009”),

            sheetInfo:getFrameIndex(“ayam_anak1_0010”),

            sheetInfo:getFrameIndex(“ayam_anak1_0011”),

            sheetInfo:getFrameIndex(“ayam_anak1_0012”),

            sheetInfo:getFrameIndex(“ayam_anak1_0013”),

            sheetInfo:getFrameIndex(“ayam_anak1_0014”),

            sheetInfo:getFrameIndex(“ayam_anak1_0015”),

            sheetInfo:getFrameIndex(“ayam_anak1_0016”),

            sheetInfo:getFrameIndex(“ayam_anak1_0017”),

            sheetInfo:getFrameIndex(“ayam_anak1_0018”)

        }, 

        time = 500, 

        loopCount = 0, 

        loopDirection = “forward”

    }

}

local ayam_anak1 = display.newSprite( myImageSheet, sequenceData )

ayam_anak1.x = _w

ayam_anak1.y = _h

ayam_anak1:play()

print( ayam_anak1.isPlaying )

print( ayam_anak1.frame )

print( ayam_anak1.numFrames )

print( ayam_anak1.sequence )

–====================================================================–

thank for the clue (hint)

But now, I have another question to ask for, after publish,

my images/melur_kiambang/001/ayam_anak1/ayam_anak1.png file have 2 frame in red colour

Here, I attach the ayam_anak1.tps file in JPG format for you to view, please let me know why got red color at some frame? Is it because I use the advance function which is not support in the Texture Packer GUI Lite Version

Or,

anyone please help, thank

thank

Not sure if setting the sequence is required, but try putting ayam_anak1:setSequence(“walking”) right before the call to play the sequence.

 Jay

Okay, setSequence shouldn’t be required, but in looking at your code I see you’re getting the image sheet data differently than I do (also using TexturePacker):

local sheetInfo = require("images.player") local myImageSheet = graphics.newImageSheet( "images/player.png", sheetInfo:getSheet() )

The sheetInfo:getSheet() is the part that’s really different.

 Jay

Hi Jay,

–====================================================================–
– this is the content of my main.lua file
–====================================================================–

display.setStatusBar( display.HiddenStatusBar )

local _w = display.contentWidth/2
local _h = display.contentHeight/2

background = display.newImage( “images/melur_kiambang/001/bg.png”, true )
background.x = _w
background.y = _h

local sheetData1 = require “images.melur_kiambang.001.ayam_anak1.ayam_anak1”
local imageSheet = graphics.newImageSheet( “images/melur_kiambang/001/ayam_anak1/ayam_anak1.png”, sheetData1:getSheet() )

local sequenceData =
{
        name=“walking”,
        start=3,
        count=6,
        time=2000,        – Optional. In ms.  If not supplied, then sprite is frame-based.
        loopCount = 0,    – Optional. Default is 0 (loop indefinitely)
        loopDirection = “forward”    – Optional. Values include: “forward”,“bounce”
}

local ayam_anak1 = display.newSprite( imageSheet, sequenceData )
ayam_anak1.x = _w
ayam_anak1.y = _h
ayam_anak1:play()

print( ayam_anak1.isPlaying )
print( ayam_anak1.frame )
print( ayam_anak1.numFrames )
print( ayam_anak1.sequence )

I try it (the text in bold) but got the error as below:

Runtime error

c:…\main.lua:23: attempt to call method ‘getSheet’ <a nil value>

stack traceback:

     [C]: in function ‘getSheet’

     c:…\main.lua:23: in main chunk

Hi Jay,

I try to attach the source as test.rar, but it say that the format that I try to attach don’t have the permit

If I want to include the source(main.lua, … ayam_anak1.tps) for your reference, pls let me know how to do it

thank

Hi Jay,

from what u mention at

local sheetInfo = require(“images.player”)
local myImageSheet = graphics.newImageSheet( “images/player.png”, sheetInfo:getSheet() )

then at http://www.coronalabs.com/blog/2013/04/18/guest-piece-an-introduction-to-texturepacker/

I find that I didn’t set the  Data Format  to **Corona SDK (image sheet) **at my images.melur_kiambang.001.ayam_anak1.ayam_anak1.lua file (the previous - I set it as Corona TM SDK)

Here is the corrected version of the main.lua file that I fix this morning until now

–====================================================================–

display.setStatusBar( display.HiddenStatusBar )

local _w = display.contentWidth/2

local _h = display.contentHeight/2

background = display.newImage( “images/melur_kiambang/001/bg.png”, true )

background.x = _w

background.y = _h

local sheetInfo = require( “images.melur_kiambang.001.ayam_anak1.ayam_anak1” )

local myImageSheet = graphics.newImageSheet( “images/melur_kiambang/001/ayam_anak1/ayam_anak1.png”, sheetInfo:getSheet() )

local sequenceData = {

    {

        name = “eat”, 

        frames = { 

            sheetInfo:getFrameIndex(“ayam_anak1_0007”),

            sheetInfo:getFrameIndex(“ayam_anak1_0008”),

            sheetInfo:getFrameIndex(“ayam_anak1_0009”),

            sheetInfo:getFrameIndex(“ayam_anak1_0010”),

            sheetInfo:getFrameIndex(“ayam_anak1_0011”),

            sheetInfo:getFrameIndex(“ayam_anak1_0012”),

            sheetInfo:getFrameIndex(“ayam_anak1_0013”),

            sheetInfo:getFrameIndex(“ayam_anak1_0014”),

            sheetInfo:getFrameIndex(“ayam_anak1_0015”),

            sheetInfo:getFrameIndex(“ayam_anak1_0016”),

            sheetInfo:getFrameIndex(“ayam_anak1_0017”),

            sheetInfo:getFrameIndex(“ayam_anak1_0018”)

        }, 

        time = 500, 

        loopCount = 0, 

        loopDirection = “forward”

    }

}

local ayam_anak1 = display.newSprite( myImageSheet, sequenceData )

ayam_anak1.x = _w

ayam_anak1.y = _h

ayam_anak1:play()

print( ayam_anak1.isPlaying )

print( ayam_anak1.frame )

print( ayam_anak1.numFrames )

print( ayam_anak1.sequence )

–====================================================================–

thank for the clue (hint)

But now, I have another question to ask for, after publish,

my images/melur_kiambang/001/ayam_anak1/ayam_anak1.png file have 2 frame in red colour

Here, I attach the ayam_anak1.tps file in JPG format for you to view, please let me know why got red color at some frame? Is it because I use the advance function which is not support in the Texture Packer GUI Lite Version

Or,

anyone please help, thank

thank