Sprites, frameproblems

Hey, forum!

I got a problem, probably an easy fix, but I can’t seem to figure it out.

  
require "sprite"  
  
local sheet2 = sprite.newSpriteSheet( "africanamerican.png", 32, 32 )  
  
local spriteSet2 = sprite.newSpriteSet(sheet2, 1, 12)  
sprite.add( spriteSet2, "man", 1, 12, 10000, 0 ) -- play 15 frames every 200 ms  
  
local instance2 = sprite.newSprite( spriteSet2 )  
instance2.x = display.contentWidth/2  
instance2.y = display.contentHeight/2  
  
instance2:prepare("man")  
instance2:play()  
  

the problem is on line 5 “local spriteSet2 = sprite.newSpriteSet(sheet2, 1, 12)” when I change the frames that will be shown to 10, 12, I get an error saying “sequence frames must be inside the sheet”.

It works fine when i type 1, 12 or any other combination not including double digits in the first frame shown.

Also, my sprite has 12 sheets.

Please help me!

EDIT: sorry about the racism guys! [import]uid: 57686 topic_id: 9846 reply_id: 309846[/import]

sprite.add( spriteSet2, “man”, 1, 12, 10000, 0 ) – play 15 frames every 200 ms

if you want to play only 11 and 12 then above line should be

sprite.add( spriteSet2, “man”, 11, 12, 10000, 0 )

and if want to play after 200 ms then

sprite.add( spriteSet2, “man”, 11, 12, 200, 0 ) [import]uid: 12482 topic_id: 9846 reply_id: 35878[/import]

You should read the API more carefully: sprite.add

startFrame
Number: The number the first frame in the sequence.

frameCount
Number: The total number of frames in the sequence. If frameCount is negative, the sequence starts playing backwards. For example, startFrame = 3 and frameCount = -3 will play frames in a 3, 2, 1 order.

It’s not “endFrame” but “frameCount”.

Correct code:
[lua]sprite.add( spriteSet2, “man”, 10, 3, 10000, 0 )[/lua] [import]uid: 51516 topic_id: 9846 reply_id: 35879[/import]

nice one i really take that as “endFrame”

but now as i had got right thing i am in trouble

this is my basic code runs 1 to 15 frame perfect…

[lua]local eagleSprite = sprite.newSpriteSheet( “eagle.png”, 55, 95, 15 )
local eagleSprite_set = sprite.newSpriteSet(eagleSprite, 1, 15 )
sprite.add( eagleSprite_set, “eagleSprite_set”, 1, 15, 500, 0 )
local eagle = sprite.newSprite( eagleSprite_set )
eagle:prepare(“eagleSprite_set”)
eagle.x = 512
eagle.myName = “eagle”
eagle.y = 240
eagle:play()[/lua]

now edited line 3

sprite.add( eagleSprite_set, “eagleSprite_set”, 10, 5, 500, 0 )

which runs frame 10 to 15

again edited
sprite.add( eagleSprite_set, “eagleSprite_set”, 10, 1, 500, 0 )

only frame 10

but now ,

sprite.add( eagleSprite_set, “eagleSprite_set”, 15, -10, 500, 0 )

got the error

even whenever i give negative number i got error why?? [import]uid: 12482 topic_id: 9846 reply_id: 35886[/import]

That’s what you get for not paying attention in Math classes :slight_smile:

sprite.add( eagleSprite_set, “eagleSprite_set”, 10, 5, 500, 0 )

which runs frame 10 to 15.

Wrong. Frame 10 to 14.
[lua]local eagleSprite_set = sprite.newSpriteSet(eagleSprite, 1, 15 )[/lua]

15 sprites. That’s sprite 1 to sprite … 14.

Correct code:
[lua]sprite.add( eagleSprite_set, “eagleSprite_set”, 14, -10, 500, 0 )[/lua] [import]uid: 51516 topic_id: 9846 reply_id: 35888[/import]

nope dude not working

sprite.add( eagleSprite_set, “eagleSprite_set”, 14, -10, 500, 0 )

not even

sprite.add( eagleSprite_set, “eagleSprite_set”, 14, -5, 500, 0 )

and about my maths its a terrible :):):):):slight_smile: [import]uid: 12482 topic_id: 9846 reply_id: 35890[/import]

i had also same issue with jungle scence example

on line 68 i was unable to run with negative number

sprite.add( spriteSet1, “cat”, 1, 8, 1000, 0 ) – play 8 frames every 1000 ms

any negative number instead of 8

or do i need to change anything else which i am not changing

can u plz tell me where to change in that example to run with negative number [import]uid: 12482 topic_id: 9846 reply_id: 35892[/import]

If you’re sure about your sprite frame number, there is nothing more I can do. File a bug report with Ansca and hope for the best. [import]uid: 51516 topic_id: 9846 reply_id: 35894[/import]

nope dude not sure as you can see till now i was treating as endframe instead of framecount

and about my spritesheet i need to play it from 1 to 15 no need of negative number as i am playing all the images

and reason for the jungle scene example is due to we both have same example i had just changed line 68 as given below

sprite.add( spriteSet1, “cat”, 7, -3, 1000, 0 )

and getting error so just want to know

thanks and bye :slight_smile: [import]uid: 12482 topic_id: 9846 reply_id: 35896[/import]

Thanks, for the input, although not directly for me. Finally understand now!

[import]uid: 57686 topic_id: 9846 reply_id: 35897[/import]