-
Notifications
You must be signed in to change notification settings - Fork 3
Lua API: MacintoshColorIcon
The MacintoshColorIcon class is used to load, and manage a cicn resource, and from which an Entity can be spawned.
Macintosh ColorIcons are one of the Legacy Assets (as in they are a Legacy format, not legacy code) and a fundamental image format supported by Kestrel. They can represent small single frame images, otherwise referred to as icons.
Be sure to read the documentation of Image Assets and Entities in Kestrel to get a better understanding of how Kestrel handles image assets.
Loading a cicn resource (indeed any image asset) is a trivial task in Kestrel. However there are 2 methods of accomplishing this, depending on whether you want to have asset caching or not.
-- Load the cicn of #128
local icon = MacintoshColorIcon(Resource.id(128))-- Load the cicn of #128
local icon = MacintoshColorIcon.load(Resource.id(128))You'll almost always want to use the second option, to avoid having to redecode the icon everytime you request it. However if you have an icon that appears only once, or infrequently you may opt to use the first option.
The following methods are exposed on the MacintoshColorIcon class.
| Method Name | Return Type | Lua API Version |
|---|---|---|
load(ResourceReference) |
MacintoshColorIcon |
v0.0.1 |
Returns a reference to the requested MacintoshColorIcon from cache, or if the requested icon could not be found, loads and caches the icon before returning a reference to the caller.
local icon = MacintoshColorIcon.load(Resource.id(128))The following properties are exposed on MacintoshColorIcon.
| Property Name | Type | Lua API Version |
|---|---|---|
size |
Size |
v0.0.1 |
Returns a structure that contains the width and the height of the icon.
The following methods are exposed on the MacintoshColorIcon instances.
| Method Name | Return Type | Lua API Version |
|---|---|---|
spawnEntity(Vec2) |
Entity |
v0.0.1 |
Returns a new Entity instance at the specified coordinates. The entity is configured to use the icon as its sprite sheet.
local alertIndicator = alertIcon:spawnEntity(Vec2(0, 0)) -- alertIndicator is an Entity
scene:render(function()
alertIndicator:draw()
end)