Game Development Reference
In-Depth Information
Text Wrapping
While drawing the text, you can also set the width of the text to be displayed, and any text that
exceeds that width gets wrapped to the next line. If the text wrap setting is set to 0, text is not
wrapped.
textWrapWidth(80)
text("This text would get wrapped onto multiple lines",100,100)
Changing the Font
The
font
function can be used for rendering text. The fonts that can be set on the iOS device are
Helvetica
.
fontSize
function can be used to change the size of the font being rendered. The default size for
sprite
sprite packs
from which
but instead refer to the image as
SpritePack
:
SpriteName
. This function requires at least three
arguments: the
spriteName
, or the
image handle
, and the x,y-coordinates where the sprites will be
positioned. The function can also take the width and height as arguments.
sprite("Planet Cute:Grass Block", WIDTH/2, HEIGHT/2)
Note
In the current version of Codea, you can also use images from the photo library or the clipboard
on the device, as well as images from Dropbox and from the library of free sprites available in Codea
Images loaded from the device or an online source can be used as sprites in Codea. To determine
the size of the sprites, you can use the function
spriteSize
, which returns the width and height of
the sprite name passed to the function.
sprWidth, sprHeight = spriteSize("Planet Cute:Grass Block)
print(sprWidth, sprHeight)
You can also set the
sprite mode
, which determines how the sprite is displayed on the screen. The
x,y-coordinates are used to position the sprite, just like the options for drawing. The default value
for
SpriteMode
is
CENTER
. The other modes that can be set are
RADIUS
,
CORNER
, and
CORNERS
, which
function similarly to the modes used for drawing ellipses and rectangles.