Sprite sheet validation

Hello. Can someone please validate whether or not my code below is typed correctly?

Please consider…and thanks.

**local function goodName (event)   
        local sheetData = { width =104, height=104, numFrames=6 }

local imageSheet = graphics.newImageSheet ( “sprites/mySprite.png”, sheetData )

local sequenceData = { { name=“glow”, start=1, count=6, time=1150 }}

local myObject = display.newSprite ( imageSheet, sequenceData )

myObject.x = display.contentCenterX -7**
myObject**.y = display.contentCenterY +10**
myObject**.alpha=.95**
myObject** :scale (1,1)**
myObject** :setSequence (“glow”)
    **** myObject **** :play()
        end**

I used this a few days ago without issue, but now my project runs with no errors and the sprite sheet is not their…Or maybe it is but I can’t see it on the screen. I’m positive I didn’t change anything else in the code, so I am just not sure why it is not working. Im pretty sure the code above is typed right, but it isnt working so Im here now with you! :slight_smile:

Any help is appreciated.

Thank you again, all.


hi, first at all - why put everything in the function(goodName) and if that function is event, suppose we need to add an object event listener to call that function, but I can’t see it at your code

  1  local function goodName (event)   

  2

  3      local sheetData = { width =104, height=104, numFrames=6 }

  4      local imageSheet = graphics.newImageSheet ( “sprites/mySprite.png”, sheetData )

  5      local sequenceData = { name=“glow”, start=1, count=6, time=1150 }

  6      local myObject = display.newSprite ( imageSheet, sequenceData )

  7

  8      myObject.x = display.contentCenterX -7

  9      myObject.y = display.contentCenterY +10

10      myObject.alpha=.95

11      myObject:scale (1,1)

12      myObject:setSequence (“glow”) – if only have 1 sequence, then can delete this line

13      myObject:play()

14

15  end

16

17  object:addEventListener( eventName, listener )

my example:

local sheetData = { width=104, height=104, numFrames=6 }

local imageSheet = graphics.newImageSheet ( “sprites/mySprite.png”, sheetData )

local sequenceData = { name=“glow”, start=1, count=6, time=1150 }

local myObject = display.newSprite ( imageSheet, sequenceData )

myObject.x = display.contentCenterX -7

myObject.y = display.contentCenterY +10

local function mySpriteListener( event )

    if ( event.phase == “ended” ) then

        local thisSprite = event.target --“event.target” references the sprite

        thisSprite:play()

    end

end

myObject:addEventListener( “touch”, mySpriteListener )

hope this can help

I cant get any form of “myVar:addEventListener( “tap”, myFunction )” to work, except, It seems to respond fine to Runtime:addEventListener (which makes the whole screen tappable instead of just the sprite…; not what I wanted, but it works), so Im sticking with it! lol, thanks. :slight_smile:

Did u double check to make sure your mySprite.png is locate inside the forder sprites?

Or

just tell me in more details what u want, see either I can help or not?

try to check either your animation is running or not by type the below

print( myObject.isPlaying )

at the last line of your code

hi, first at all - why put everything in the function(goodName) and if that function is event, suppose we need to add an object event listener to call that function, but I can’t see it at your code

  1  local function goodName (event)   

  2

  3      local sheetData = { width =104, height=104, numFrames=6 }

  4      local imageSheet = graphics.newImageSheet ( “sprites/mySprite.png”, sheetData )

  5      local sequenceData = { name=“glow”, start=1, count=6, time=1150 }

  6      local myObject = display.newSprite ( imageSheet, sequenceData )

  7

  8      myObject.x = display.contentCenterX -7

  9      myObject.y = display.contentCenterY +10

10      myObject.alpha=.95

11      myObject:scale (1,1)

12      myObject:setSequence (“glow”) – if only have 1 sequence, then can delete this line

13      myObject:play()

14

15  end

16

17  object:addEventListener( eventName, listener )

my example:

local sheetData = { width=104, height=104, numFrames=6 }

local imageSheet = graphics.newImageSheet ( “sprites/mySprite.png”, sheetData )

local sequenceData = { name=“glow”, start=1, count=6, time=1150 }

local myObject = display.newSprite ( imageSheet, sequenceData )

myObject.x = display.contentCenterX -7

myObject.y = display.contentCenterY +10

local function mySpriteListener( event )

    if ( event.phase == “ended” ) then

        local thisSprite = event.target --“event.target” references the sprite

        thisSprite:play()

    end

end

myObject:addEventListener( “touch”, mySpriteListener )

hope this can help

I cant get any form of “myVar:addEventListener( “tap”, myFunction )” to work, except, It seems to respond fine to Runtime:addEventListener (which makes the whole screen tappable instead of just the sprite…; not what I wanted, but it works), so Im sticking with it! lol, thanks. :slight_smile:

Did u double check to make sure your mySprite.png is locate inside the forder sprites?

Or

just tell me in more details what u want, see either I can help or not?

try to check either your animation is running or not by type the below

print( myObject.isPlaying )

at the last line of your code