[Resolved] How to set sprite frame?

Hi,

I have some identic sprite objects. I want to set them random frames. If I use setFrame method I get this error: “attempt to call method ‘setFrame’ (a nil value)”
I found if sprite object created as display.newSprite, this method works fine. But if sprite created as sprite.newSprite not works.
How I can set sprites frame?

Rustam. [import]uid: 108150 topic_id: 31300 reply_id: 331300[/import]

It sounds like you may be mixing the new Sprite API and the old Sprite API. If you use sprite.newSprite you should be able to set it using sprite.currentFrame = 1 (or the like) [import]uid: 52491 topic_id: 31300 reply_id: 125225[/import]

thank you very much Peach! [import]uid: 108150 topic_id: 31300 reply_id: 125231[/import]

You’re welcome, good luck with your project :slight_smile: [import]uid: 52491 topic_id: 31300 reply_id: 125351[/import]

It sounds like you may be mixing the new Sprite API and the old Sprite API. If you use sprite.newSprite you should be able to set it using sprite.currentFrame = 1 (or the like) [import]uid: 52491 topic_id: 31300 reply_id: 125225[/import]

thank you very much Peach! [import]uid: 108150 topic_id: 31300 reply_id: 125231[/import]

You’re welcome, good luck with your project :slight_smile: [import]uid: 52491 topic_id: 31300 reply_id: 125351[/import]