Reader small image

You're reading from  Corona SDK Mobile Game Development: Beginner's Guide

Product typeBook
Published inMar 2015
Publisher
ISBN-139781783559343
Edition1st Edition
Tools
Right arrow
Author (1)
Michelle M Fernandez
Michelle M Fernandez
Right arrow

It's sprite mania!


Image sheets are 2D animations that compile multiple frames into a single texture image. This is an efficient way to save on texture memory. It is beneficial for mobile devices and minimizes the loading time.

Image sheet API

The graphics.newImageSheet function creates a new image sheet. Refer to the following code:

graphics.newImageSheet( filename, [baseDir, ] options )

For example, the number of frames in the image sheet is assumed to be floor(imageWidth/frameWidth) * floor(imageHeight/frameHeight). The first frame is placed at the top-left position and reads left to right and follows the next row, if applicable. The following image sheet has five frames that are 128 x 128 pixels each. The image sheet image is 384 pixels x 256 pixels altogether. If it were to be integrated in Corona, a sample method would be displayed like this:

local options =
{
  width = 128,
  height = 128,
  numFrames = 5,
  sheetContentWidth=384, 
  sheetContentHeight=256
}
local sheet = graphics.newImageSheet...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Corona SDK Mobile Game Development: Beginner's Guide
Published in: Mar 2015Publisher: ISBN-13: 9781783559343

Author (1)