director class animation problem

Could someone help please.
I use the director class to transition from screen to screen with no problem.
But one of my screen contain the following code and the Director class give me an error.
Can anyone help me please

module(…,package.seeall)
require “sprite”


– this is the basic display group

function new()
local localGroup = display.newGroup()
local background = display.newImage(“Graphics/main2.png”)
local data = require(“professor_default”).getSpriteSheetData()
local sheet = sprite.newSpriteSheetFromData (“professor.png”,data)


– inserting these lines cause Director error- failed to execute new(params) function on menu

–local set = sprite.newSpriteSet(sheet,1,16)
–local instance =sprite.newSprite(set)
–instance.x = 512
–instance.y = 300
–instance:play()

localGroup:insert(background)
– localGroup:insert(instance)

return localGroup
end [import]uid: 81215 topic_id: 21751 reply_id: 321751[/import]

The first thing that jumps out to me is you aren’t preparing the sprite, just trying to play it. [import]uid: 52491 topic_id: 21751 reply_id: 86429[/import]

Thank you for your reply

Im not sure what you mean about preparing the sprite.

i thought this two line of code does that. Im a newbie.

–local set = sprite.newSpriteSet(sheet,1,16)
–local instance =sprite.newSprite(set)
[import]uid: 81215 topic_id: 21751 reply_id: 86521[/import]

Take a look at;
CoronaSDK > SampleCode > Sprites > JungleScene

In that folder open main.lua and take a look at instance1. You will see this code;

[lua]-- A sprite sheet with a cat
local sheet1 = sprite.newSpriteSheet( “runningcat.png”, 512, 256 )

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

local instance1 = sprite.newSprite( spriteSet1 )
instance1.x = display.contentWidth / 4 + 40
instance1.y = baseline - 75
instance1.xScale = .5
instance1.yScale = .5

instance1:prepare(“cat”)
instance1:play()[/lua]
See how the cat is prepared immediately before play?

Peach :slight_smile: [import]uid: 52491 topic_id: 21751 reply_id: 86557[/import]

Thanks you. Much appreciated, nice to know someone is always willing to help out. Cheers [import]uid: 81215 topic_id: 21751 reply_id: 87230[/import]

Not a problem Albert, any more issues just give a shout :slight_smile: [import]uid: 52491 topic_id: 21751 reply_id: 87243[/import]