Yohane, able to run in every game environment which uses Lua 5.1 to allow images to be loaded and a timer function which is called for every game frame update.
Initialize Yohane Flash Abstraction
Parameters:
-
loader
- Function to use when loadingYohaneFlash.lua
andYohaneMovie.lua
which similar to Lua functionloadfile
. Defaults toloadfile
-
sysroot
- Path whereYohaneFlash.lua
andYohaneMovie.lua
located. Defaults to current directory.
Calling this if it's already initialized is no-op
Loads Playground flash file from specificed stream/string/filename
Parameters:
-
stream
- File stream. This object must containread(number bytes)
method which reads from specificed stream -
str
- String containing the whole Playground flash contents -
filename
- Playground flash file path -
movie_name
- Once loaded, set animation to render
Returns: YohaneFlash
object
Note: PlatformImage
object in here is platform-dependant image object.
Clone current YohaneFlash
object to new instance
Returns: New YohaneFlash
object with same animation data
Updates YohaneFlash
object state (like running animation instruction)
Parameter:
deltaT
- Time difference between 2 time points, in milliseconds
Draws animation, optionally in specificed coordinates
Parameters:
-
x
- X coordinate -
y
- Y coordinate
Set animation to render
Parameters:
movie_name
- Animation name
This function automatically unfreeze the flash animation
Jumps animation to specificed label name
Parameters:
label_name
- Jump to this label
This function automatically unfreeze the flash animation
Sets pseudo-image to specificed image. Pseudo-image name starts with %
prefix.
Parameters:
-
pseudo_image_name
- Pseudo image name, withoutI%
prefix -
image
- New image to set (ornil
to clear it)
Set animation opacity
Parameters:
opacity
- Flash image opacity (defaults to255
)
Get PlatformImage
object for specificed image name without I
prefix and .png.imag
suffix. Pseudo-image name
must start with %
prefix
Parameters:
image_name
- Flash image name to retrieve it'sPlatformImage
object
Returns: PlatformImage
object, a platform-dependant image handle (can be anything depending on platform).
Check if current flash is frozen. That's it, it encounter STOP_INSTRUCTION
. Frozen flash animation doesn't get
updated when YohaneFlash:update(deltaT)
is called.
Returns: true
if it's frozen, false
otherwise.
Unfreeze flash animation. Allowing it to updating when YohaneFlash:update(deltaT)
is called.
To add new compatible platform, one must implement these functions.
Note: PlatformAudio
is platform-dependant audio handle (can be anything)
Called when Yohane tries to load flash animation images
Parameters:
path
- The image path, withoutI
prefix and without.imag
suffix (PNG image)
Returns: PlatformImage
object
Example:
function Yohane.Platform.ResolveImage(path)
return love.graphics.newImage(path)
end
-- OR
Yohane.Platform.ResolveImage = love.graphics.newImage
Called when Yohane tries to clone image used by flash animation (calling YohaneFlash:clone()
for example)
Parameters:
image
-PlatformImage
object which needs to be cloned.
Returns: New PlatformImage
object.
Depending on platform, same image handle can be used (LOVE2D for example)
Called when Yohane tries to load audio used by flash animation
Parameter:
path
- The audio path, without extension. It's up to platform responsibility to add extension to it
Returns: New PlatformAudio
object or nil
on failure
Same as PlatformImage Yohane.Platform.CloneImage(PlatformImage image)
except this is for audio.
Parameters:
audio
- The audio handle. It also can benil
where in this case simply returnnil
.
Returns: New PlatformAudio
object or nil
if audio
is nil
Called when Yohane tries to play audio
Parameter:
audio
- The audio handle (can benil
)
Called when Yohane requests to draw images. drawdatalist
contains lists of images to be drawn on screen,
ordered by it's appearance (first is lowest, last is highest). For every element in there, it contains:
-
x
- Image X position (relative to topmost part of image) -
y
- Image Y position (relative to leftmost part of image) -
scaleX
- Image scale X -
scaleY
- Image scale Y -
rotation
- Image rotation (in radians) -
r
,g
,b
,a
- Image colors (RGBA). Values range from 0-255
Parameters:
drawdatalist
- Lists of images to be drawn in their respective order
Example:
function Yohane.Platform.Draw(drawdatalist)
local r, g, b, a = love.graphics.getColor()
for _, drawdata in ipairs(drawdatalist) do
if drawdata.image then
love.graphics.setColor(drawdata.r, drawdata.g, drawdata.b, drawdata.a)
love.graphics.draw(drawdata.image, drawdata.x, drawdata.y, drawdata.rotation, drawdata.scaleX, drawdata.scaleY)
end
end
love.graphics.setColor(r, g, b, a)
end
Called when Yohane tries to load flash image specificed in path
(calling Yohane.newFlashFromFilename
for example).
This function is optional and defaults to io.open
if none is found
Parameters:
path
- Path to the file
Returns: File stream