How do I work with static sprites?

Hi,

I am new to Corona, and am currently working on creating a simple eBook. This book will be created from multiple objects, organized in layers (background, trees, main character, etc). I checked the sprites documentation but found only means of creating animations. What I am hoping for, is to use sprite sheets for background and static sprites as well. This should decrease memory usage, since images don’t need to be transformed in power of 2 sizes.

I am using Zwoptex for creating an atlas, but am unable to figure out how to extract sprites from it.

Pseudo code:

local spritesheet = …

local tree1 = spritesheet:getSprite(“Tree1.png”) – Where Tree1.png is the name given by Zwoptex

Can anyone help me write this code correctly for Corona SDK?

Thanks [import]uid: 127214 topic_id: 23351 reply_id: 323351[/import]

I haven’t used Zwoptex but if it spits out a sheet could you try setting the frame, perhaps? [import]uid: 52491 topic_id: 23351 reply_id: 93707[/import]

Well the point is that I would have sprites of various sizes in that sprite sheet. Setting the frame only will not help.

Also, when creating sprite sets or sprites, you are unable to define them by name.

Let me give you an example of what I need. I have a sprite sheet. In it I have a tree of 50x100 px and another tree of 125x200 px. How do I define 2 sprites of different resolutions?

Unless I am missing something, I feel this is a pretty basic functionality that should exist. This is the way Cocos 2D does it and it has the following advantages:

  • reduces the number of draw calls
  • reduces memory usage. There is no need to re-size textures to the closest power of 2 size [import]uid: 127214 topic_id: 23351 reply_id: 93715[/import]