After changed scene by using SceneManager ,I got error about sprite animation

“attempt to call method ‘prepare’ (a nil value) stack traceback”

I have checked that the sprite instance is not nil.
The issue occured when I retried the stage.
[lua] scene:changeScene(“Level1Stage”, “fade”)
–Do I have to set something more?[/lua]
Is there anybody has the same experience?
If I’m correct, this problem also occured when I use director class. Why does this happen? [import]uid: 65906 topic_id: 15838 reply_id: 315838[/import]

everything in first file is removed when you change scenes to release memory you have to reload or set all images to a higher scope then local to each file [import]uid: 7911 topic_id: 15838 reply_id: 58527[/import]

If this happens with director and sceneManager the trouble shooter in me says there is an issue with your code how are you setting up you sprites. [import]uid: 39088 topic_id: 15838 reply_id: 58529[/import]

[lua]–animationTouch

module(…, package.seeall)

function new()
local localGroup = display.newGroup();
local sprite = require(“sprite”)
local sheet = sprite.newSpriteSheet(“images/touchSimple.png”, 50, 50)

local spriteSet = sprite.newSpriteSet(sheet, 1, 2)
sprite.add(spriteSet, “touchMe”, 1, 2, 10, 1)
local instance = sprite.newSprite(spriteSet)
instance:setReferencePoint(display.CenterReferencePoint);
instance.x = -500;
instance.y = -500;

localGroup:insert(instance);
function touchHandle(e)

if (e.phase == “began”) then
instance.x = e.x;
instance.y = e.y;
instance:prepare(“touchMe”)
instance:play()
end
if (e.phase == “moved”) then
instance.x = e.x;
instance.y = e.y;
end

if (e.phase == “ended”) then
instance.x = defaultPos;
instance.y = defaultPos;
end
end

Runtime:addEventListener(“touch”, touchHandle);
return localGroup;
end[/lua]

[lua]–stage1.lua
local locaGroup = display.newGroup();
local touchIcon = require(“animationTouch”).new()
localGroup:insert(touchIcon);[/lua]
@skalistican6 , here is my code.
Everything is fine for the first time but I got error which I’ve already mention in replay the scene.

@jstrahan
I do not get what you mention. Could you please give me some sample? [import]uid: 65906 topic_id: 15838 reply_id: 58534[/import]

I was unaware you were using an external function to handle your sprites. I wish I could help you, but im afraid I am just now diving into the subject myself. Typicly I keep the code for my spritesheets on each level file.

I did notice that when you play your sprite you did not use

instance:prepare(“touchMe”)
instance:play(“touchMe”)

you had
instance:prepare(“touchMe”)
instance:play()

Not sure if that would cause the issue or not. Probably something about using that external spritesheet though. [import]uid: 39088 topic_id: 15838 reply_id: 58537[/import]

i may have miss understood you

i just fixed something like this in a demo im working on i think what i did was nil the variables and reset them [import]uid: 7911 topic_id: 15838 reply_id: 58538[/import]

@jstrahan
Could you explain in detail what do you mean “reset”?
Or could you please show me some example code?

@skalistican6
I used play() following the api document.
I have no idea what is different between play(sequence) and play().

Anyway, thanks for every advices [import]uid: 65906 topic_id: 15838 reply_id: 58568[/import]

won’t be home from work for few hours then I’ll take a closer look [import]uid: 7911 topic_id: 15838 reply_id: 58582[/import]

also problem with the sprite Sprites wouldnt show up in the test device. Simulator showes everything. Tested it with the director too. [import]uid: 86417 topic_id: 15838 reply_id: 59904[/import]

I had a similar issue saying prepare was nil. If you want to keep your existing set up here is a quick workaround …

[code]

if obj.prepare then
obj:prepare(“whatever”)
end

[/code] [import]uid: 84637 topic_id: 15838 reply_id: 59910[/import]

it seems to have problems with loading the spritesheet, but i dont know why. Maybe somebody can help me out? [import]uid: 86417 topic_id: 15838 reply_id: 59915[/import]

Texturesize was too big. Fix it myself. But it is stupid that the simulator show it. [import]uid: 86417 topic_id: 15838 reply_id: 59921[/import]

@martin.edmaier

Can you provide a little more info ? [import]uid: 84637 topic_id: 15838 reply_id: 59922[/import]

TextureSize in the TexturePacker was 2024 x 2024. I changed it to 512 x 512 now it works on my htc s…

The problem seems that didnt load the file and then i got a black screen. But when i use functions the loading seems to ignored.

And the sprites didnt show up.

But in the simulator everything looks fine. [import]uid: 86417 topic_id: 15838 reply_id: 59925[/import]