moonphaserkit

A MoonBit JavaScript binding for Phaser 3 scenes, sprites, animation, audio, camera, tilemaps, input, text, and Arcade Physics.

phaser
game
binding
javascript
web
arcade-physics
animation
audio
camera
tilemap
touch
moon add Ridge-Lab/moonphaserkit@0.3.0
Download zip
Author
Version
0.3.0
License
MIT
Last updated
last month
Downloads
8
README

#MoonPhaserKit

MoonPhaserKit 是面向 MoonBit JavaScript 后端的 Phaser 3 轻量游戏开发绑定库。它让开发者用 MoonBit 编写 2D 网页游戏逻辑,并调用 Phaser 3 的场景、精灵、输入、动画、音频、相机、Tilemap 和 Arcade Physics 能力。

本项目用于 2026 MoonBit 国产基础软件生态开源大赛。项目定位不是提交一个小游戏,而是补齐 MoonBit Web 游戏生态中“用 MoonBit 写浏览器 2D 游戏”的基础绑定能力;示例游戏 Moon Jumper 用来验证绑定链路、工程接入方式和浏览器运行效果。

#交付范围

  • 核心语言:MoonBit,目标后端为 JavaScript。
  • 绑定目标:Phaser 3,Demo 与 CI 固定使用 phaser@3.90.0
  • 公开 API:游戏创建、场景生命周期、资源加载、精灵、文字、动画、音频、键盘、触控指针、相机、Tilemap、Arcade Physics、碰撞、场景控制和时间事件。
  • 示例工程:examples/moon-jumper-web,使用 Vite 启动网页 Demo。
  • 工程质量:包含 MoonBit 单元测试、白盒测试、浏览器 smoke test、CI、API 文档、集成指南、测试说明和提交说明。
  • 设计边界:v1 只支持 MoonBit JavaScript 后端 + Phaser 3;不覆盖 Phaser 4、Godot、Cocos、Unity、Unreal、原生桌面端和原生移动端。

#评审反馈处理

针对预验收反馈,本仓库已完成以下增强:

  • 源码规模从早期轻量原型扩展到 4k+ 行 MoonBit 源码,新增动画、音频、相机、Tilemap、触控、场景控制、时间事件、UI 文本样式、兼容性模型和诊断模型。
  • 测试从基础配置测试扩展为 40 个 MoonBit 测试用例,并保留浏览器 smoke test,覆盖配置、资源、动画、音频、相机、Tilemap、触控、错误路径、交互场景和新增运行时模型。
  • README 已改为源码验收、Mooncakes 包元数据和比赛提交分别说明,避免产生提交物未完成的印象。
  • 文档补充 API 示例、版本兼容、项目集成、测试方式和提交检查清单。

#安装与使用

源码方式,适合评审和本地验收:

git clone https://github.com/Ridge-Lab/MoonPhaserKit.git cd MoonPhaserKit moon check --target js moon test --target js

Mooncakes 方式用于包索引和依赖安装验收。当前模块名配置为 Ridge-Lab/moonphaserkit;发布或更新当前版本时,请确认 moon.mod/ 前面的 owner 与实际 Mooncakes 用户名一致,然后执行:

moon publish

发布成功后,其他项目可以使用对应包名安装,例如:

moon add Ridge-Lab/moonphaserkit

宿主网页需要安装 Phaser,并在加载 MoonBit 生成的 JavaScript 前暴露全局对象:

import Phaser from "phaser"; globalThis.Phaser = Phaser; await import("./generated/moon-jumper.js");

#最小示例

fn main {
let config = @moonphaserkit.GameConfig::new(parent="game")
ignore(@moonphaserkit.Game::create(
config,
scene => {
scene.load_image(@moonphaserkit.ImageAsset::new("player", "/assets/player.svg"))
scene.load_spritesheet(
@moonphaserkit.SpriteSheetAsset::new("hero-run", "/assets/hero-run.png", 32, 48),
)
scene.load_audio(@moonphaserkit.AudioAsset::new("jump", "/assets/jump.ogg"))
},
scene => {
scene.create_animation(
@moonphaserkit.AnimationConfig::new(
"run",
"hero-run",
@moonphaserkit.FrameRange::new(0, 7),
frame_rate=14,
repeat_mode=@moonphaserkit.AnimRepeatForever,
),
)
let player = scene.add_sprite(120.0, 220.0, "player")
player.apply_options(@moonphaserkit.SpriteOptions::new(collide_world_bounds=true))
player.play_animation("run")
scene.main_camera().start_follow(player)
ignore(scene.delayed_call(@moonphaserkit.DurationMs::seconds(1), () => {
player.set_tint(0xffcc00)
}))
},
_scene => (),
))
}

#运行 Demo

cd examples/moon-jumper-web corepack enable pnpm install --frozen-lockfile pnpm run dev

打开 Vite 输出的本地地址后,使用方向键左、右、上进行移动和跳跃;在移动端视口可以点击画布触发跳跃。

#验收命令

在提交或评审前建议依次执行:

moon check --target js moon test --target js cd examples/moon-jumper-web corepack enable pnpm install --frozen-lockfile pnpm run build pnpm run smoke

其中 pnpm run smoke 会启动浏览器检查 Phaser canvas 是否出现、桌面和移动视口是否正常、键盘交互是否可触发,以及页面是否出现 console error 或 HTTP 错误。

#API 概览

类别公开能力
游戏与场景GameConfigGameScene,支持 Phaser 游戏创建、销毁和场景生命周期。
场景控制SceneControlCommandstart_scenelaunch_scenepause_sceneresume_scenestop_scenesleep_scenewake_scene
时间事件TimerEventConfigTimerEventdelayed_calladd_timer_event,支持延迟、重复和循环回调。
资源加载ImageAssetTextureAssetSpriteSheetAssetTextureAtlasAssetAudioAssetTilemapJsonAssetBitmapFontAsset
显示对象SpriteTextDisplayObjectOptionsTextStyleSpawnSpec,支持位置、缩放、透明度、层级、文字样式、显示和销毁。
动画AnimationConfigFrameRangeAnimationPlayOptionsTweenConfigSpriteTween
音频SoundSoundOptionsSoundMarkerAudioFadeAudioBusState
输入CursorKeysKeyPointerPointerSnapshotTouchZoneSwipeSnapshotKeyBinding
物理与碰撞ArcadeBodyColliderPhysicsMaterialTileCollisionRangeTilePropertyMatcher
相机CameraCameraBoundsCameraFollowOptionsCameraFadeOptionsCameraShakeOptionsCameraPanOptionsCameraZoomOptions
TilemapTilemapTilesetTileLayerTilemapConfigTilesetConfigTileLayerConfigTileObjectTileSpawnPoint
工程支撑RuntimeCompatibilityIntegrationChecklistBrowserSmokeScenarioErrorPathExpectationFfiCallRecord

#兼容性

  • MoonBit:JavaScript 后端。
  • Phaser:Demo 和 CI 固定 3.90.0;库内兼容性模型将 Phaser 3.60+ 标记为可支持窗口。
  • 浏览器:现代 Chromium、Edge、Firefox、Safari。
  • 音频:遵循浏览器用户手势解锁规则,实际项目建议在首次点击、触摸或键盘输入后播放音频。
  • 宿主要求:运行 MoonBit 生成的 JavaScript 前必须设置 globalThis.Phaser

#文档

#仓库与参赛说明

  • GitHub 仓库:https://github.com/Ridge-Lab/MoonPhaserKit.git
  • GitLink 仓库:https://gitlink.org.cn/RidgeLab/MoonPhaserKit
  • 项目性质:原创 MoonBit 生态绑定项目,不移植已有开源项目源码。
  • 许可证:MIT。

#
OverlapCallback

type OverlapCallback = (Sprite, Sprite) -> Unit

#
PointerCallback

type PointerCallback = (Pointer) -> Unit

#
SceneCallback

type SceneCallback = (Scene) -> Unit

#
TimerCallback

type TimerCallback = () -> Unit

#
UpdateCallback

type UpdateCallback = (Scene) -> Unit

#
AnimationConfig

pub(all) struct AnimationConfig {
key : String
texture_key : String
frames : FrameRange
frame_rate : Int
repeat_mode : AnimationRepeatMode
repeat_count : Int
yoyo : Bool
delay_ms : Int
} derive(Eq,
Debug
)

#
AnimationConfig::is_valid

fn AnimationConfig::is_valid(self : AnimationConfig) -> Bool

#
AnimationConfig::loops_forever

fn AnimationConfig::loops_forever(self : AnimationConfig) -> Bool

#
AnimationConfig::new

fn AnimationConfig::new(key : String, texture_key : String, frames : FrameRange, frame_rate? : Int, repeat_mode? : AnimationRepeatMode, repeat_count? : Int, yoyo? : Bool, delay_ms? : Int) -> AnimationConfig

#
AnimationConfig::phaser_repeat

fn AnimationConfig::phaser_repeat(self : AnimationConfig) -> Int

#
AnimationConfig::plays_once

fn AnimationConfig::plays_once(self : AnimationConfig) -> Bool

#
AnimationDirection

pub(all) enum AnimationDirection {
AnimForward
AnimReverse
} derive(Eq,
Debug
)

#
AnimationDirection::is_reverse

fn AnimationDirection::is_reverse(self : AnimationDirection) -> Bool

#
AnimationPlayOptions

pub(all) struct AnimationPlayOptions {
ignore_if_playing : Bool
start_frame : Int
delay_ms : Int
repeat_override : Int
} derive(Eq,
Debug
)

#
AnimationPlayOptions::is_valid

fn AnimationPlayOptions::is_valid(self : AnimationPlayOptions) -> Bool

#
AnimationPlayOptions::new

fn AnimationPlayOptions::new(ignore_if_playing? : Bool, start_frame? : Int, delay_ms? : Int, repeat_override? : Int) -> AnimationPlayOptions

#
AnimationRepeatMode

pub(all) enum AnimationRepeatMode {
AnimRepeatOnce
AnimRepeatForever
AnimRepeatFixed
} derive(Eq,
Debug
)

#
AnimationRepeatMode::to_repeat_count

fn AnimationRepeatMode::to_repeat_count(self : AnimationRepeatMode, fixed_count? : Int) -> Int

#
AnimationStateSnapshot

pub(all) struct AnimationStateSnapshot {
key : String
is_playing : Bool
progress : Double
frame_index : Int
} derive(Eq,
Debug
)

#
AnimationStateSnapshot::is_valid

fn AnimationStateSnapshot::is_valid(self : AnimationStateSnapshot) -> Bool

#
AnimationStateSnapshot::new

fn AnimationStateSnapshot::new(key : String, is_playing : Bool, progress : Double, frame_index : Int) -> AnimationStateSnapshot

#
ArcadeBody

#external
pub type ArcadeBody

A Phaser Arcade Physics body handle.

#
ArcadeBody::set_bounce

fn ArcadeBody::set_bounce(self : ArcadeBody, x : Double, y : Double) -> Unit

Sets a body's bounce.

#
ArcadeBody::set_collide_world_bounds

fn ArcadeBody::set_collide_world_bounds(self : ArcadeBody, collide : Bool) -> Unit

Sets whether the body collides with world bounds.

#
ArcadeBody::set_gravity_y

fn ArcadeBody::set_gravity_y(self : ArcadeBody, gravity_y : Double) -> Unit

Sets a body-specific vertical gravity.

#
ArcadeBody::set_immovable

fn ArcadeBody::set_immovable(self : ArcadeBody, immovable : Bool) -> Unit

Sets whether the body is immovable.

#
ArcadeBody::set_velocity

fn ArcadeBody::set_velocity(self : ArcadeBody, velocity : Velocity) -> Unit

Sets a body's x and y velocity.

#
ArcadeBody::set_velocity_x

fn ArcadeBody::set_velocity_x(self : ArcadeBody, x : Double) -> Unit

Sets a body's x velocity.

#
ArcadeBody::set_velocity_y

fn ArcadeBody::set_velocity_y(self : ArcadeBody, y : Double) -> Unit

Sets a body's y velocity.

#
ArcadeBody::touching_down

fn ArcadeBody::touching_down(self : ArcadeBody) -> Bool

Returns true when the body is standing on something.

#
AssetGroup

pub(all) struct AssetGroup {
name : String
base_path : String
} derive(Eq,
Debug
)

A logical asset group used by docs and larger examples.

#
AssetGroup::is_valid

fn AssetGroup::is_valid(self : AssetGroup) -> Bool

#
AssetGroup::new

fn AssetGroup::new(name : String, base_path : String) -> AssetGroup

#
AssetGroup::resolve

fn AssetGroup::resolve(self : AssetGroup, file_name : String) -> String

#
AssetKind

pub(all) enum AssetKind {
AssetImage
AssetSpriteSheet
AssetAtlas
AssetAudio
AssetTilemapJson
AssetBitmapFont
} derive(Eq,
Debug
)

#
AssetKind::label

fn AssetKind::label(self : AssetKind) -> String

#
AssetManifestEntry

pub(all) struct AssetManifestEntry {
kind : AssetKind
key : String
primary_path : String
secondary_path : String
} derive(Eq,
Debug
)

Lightweight manifest entry used in tests, docs, and future asset preloaders.

#
AssetManifestEntry::is_complete

fn AssetManifestEntry::is_complete(self : AssetManifestEntry) -> Bool

#
AssetManifestEntry::is_valid

fn AssetManifestEntry::is_valid(self : AssetManifestEntry) -> Bool

#
AssetManifestEntry::new

fn AssetManifestEntry::new(kind : AssetKind, key : String, primary_path : String, secondary_path? : String) -> AssetManifestEntry

#
AssetManifestEntry::requires_secondary_path

fn AssetManifestEntry::requires_secondary_path(self : AssetManifestEntry) -> Bool

#
AssetManifestEntry::secondary_path_is_valid

fn AssetManifestEntry::secondary_path_is_valid(self : AssetManifestEntry) -> Bool

#
AudioAsset

pub(all) struct AudioAsset {
key : String
path : String
} derive(Eq,
Debug
)

Audio file descriptor. The path can point to mp3, ogg, wav, or browser-supported audio.

#
AudioAsset::is_valid

fn AudioAsset::is_valid(self : AudioAsset) -> Bool

#
AudioAsset::new

fn AudioAsset::new(key : String, path : String) -> AudioAsset

#
AudioBusKind

pub(all) enum AudioBusKind {
BusMaster
BusMusic
BusEffects
BusUi
BusVoice
} derive(Eq,
Debug
)

#
AudioBusKind::label

fn AudioBusKind::label(self : AudioBusKind) -> String

#
AudioBusState

pub(all) struct AudioBusState {
kind : AudioBusKind
volume : Double
muted : Bool
} derive(Eq,
Debug
)

#
AudioBusState::effective_volume

fn AudioBusState::effective_volume(self : AudioBusState) -> Double

#
AudioBusState::is_valid

fn AudioBusState::is_valid(self : AudioBusState) -> Bool

#
AudioBusState::new

fn AudioBusState::new(kind : AudioBusKind, volume? : Double, muted? : Bool) -> AudioBusState

#
AudioFade

pub(all) struct AudioFade {
from_volume : Double
to_volume : Double
duration_ms : Int
} derive(Eq,
Debug
)

#
AudioFade::is_valid

fn AudioFade::is_valid(self : AudioFade) -> Bool

#
AudioFade::new

fn AudioFade::new(from_volume : Double, to_volume : Double, duration_ms : Int) -> AudioFade

#
BitmapFontAsset

pub(all) struct BitmapFontAsset {
key : String
texture_path : String
data_path : String
} derive(Eq,
Debug
)

Bitmap font descriptor for score panels and pixel-art UI.

#
BitmapFontAsset::is_valid

fn BitmapFontAsset::is_valid(self : BitmapFontAsset) -> Bool

#
BitmapFontAsset::new

fn BitmapFontAsset::new(key : String, texture_path : String, data_path : String) -> BitmapFontAsset

#
BrowserSmokeScenario

pub(all) struct BrowserSmokeScenario {
name : String
viewport : BrowserViewport
canvas : CanvasExpectation
initial_wait_ms : Int
fail_on_console_error : Bool
fail_on_http_error : Bool
} derive(Eq,
Debug
)

#
BrowserSmokeScenario::desktop_default

#
BrowserSmokeScenario::is_valid

fn BrowserSmokeScenario::is_valid(self : BrowserSmokeScenario) -> Bool

#
BrowserSmokeScenario::mobile_default

#
BrowserSmokeScenario::new

fn BrowserSmokeScenario::new(name : String, viewport : BrowserViewport, canvas? : CanvasExpectation, initial_wait_ms? : Int, fail_on_console_error? : Bool, fail_on_http_error? : Bool) -> BrowserSmokeScenario

#
BrowserTarget

pub(all) enum BrowserTarget {
BrowserChromium
BrowserFirefox
BrowserSafari
BrowserEdge
BrowserUnknown
} derive(Eq,
Debug
)

#
BrowserTarget::label

fn BrowserTarget::label(self : BrowserTarget) -> String

#
BrowserTarget::supports_audio_unlock

fn BrowserTarget::supports_audio_unlock(self : BrowserTarget) -> Bool

#
BrowserViewport

pub(all) struct BrowserViewport {
kind : BrowserViewportKind
width : Int
height : Int
} derive(Eq,
Debug
)

#
BrowserViewport::desktop

#
BrowserViewport::is_valid

fn BrowserViewport::is_valid(self : BrowserViewport) -> Bool

#
BrowserViewport::mobile

#
BrowserViewport::new

fn BrowserViewport::new(kind : BrowserViewportKind, width : Int, height : Int) -> BrowserViewport

#
BrowserViewportKind

pub(all) enum BrowserViewportKind {
ViewportDesktop
ViewportTablet
ViewportMobile
} derive(Eq,
Debug
)

#
BrowserViewportKind::label

fn BrowserViewportKind::label(self : BrowserViewportKind) -> String

#
Camera

#external
pub type Camera

A Phaser.Cameras.Scene2D.Camera handle.

#
Camera::center_on

fn Camera::center_on(self : Camera, point : Point2) -> Unit

#
Camera::fade_in

fn Camera::fade_in(self : Camera, options? : CameraFadeOptions) -> Unit

#
Camera::fade_out

fn Camera::fade_out(self : Camera, options? : CameraFadeOptions) -> Unit

#
Camera::pan

fn Camera::pan(self : Camera, options : CameraPanOptions) -> Unit

#
Camera::set_bounds

fn Camera::set_bounds(self : Camera, bounds : CameraBounds) -> Unit

#
Camera::set_zoom

fn Camera::set_zoom(self : Camera, zoom : Double) -> Unit

#
Camera::shake

fn Camera::shake(self : Camera, options? : CameraShakeOptions) -> Unit

#
Camera::start_follow

fn Camera::start_follow(self : Camera, sprite : Sprite, options? : CameraFollowOptions) -> Unit

#
Camera::stop_follow

fn Camera::stop_follow(self : Camera) -> Unit

#
Camera::zoom_to

fn Camera::zoom_to(self : Camera, options : CameraZoomOptions) -> Unit

#
CameraBounds

pub(all) struct CameraBounds {
x : Double
y : Double
width : Double
height : Double
} derive(Eq,
Debug
)

#
CameraBounds::as_rect

fn CameraBounds::as_rect(self : CameraBounds) -> Rect

#
CameraBounds::from_rect

fn CameraBounds::from_rect(rect : Rect) -> CameraBounds

#
CameraBounds::is_valid

fn CameraBounds::is_valid(self : CameraBounds) -> Bool

#
CameraBounds::new

fn CameraBounds::new(x : Double, y : Double, width : Double, height : Double) -> CameraBounds

#
CameraFadeOptions

pub(all) struct CameraFadeOptions {
duration_ms : Int
red : Int
green : Int
blue : Int
force : Bool
} derive(Eq,
Debug
)

#
CameraFadeOptions::is_valid

fn CameraFadeOptions::is_valid(self : CameraFadeOptions) -> Bool

#
CameraFadeOptions::new

fn CameraFadeOptions::new(duration_ms? : Int, red? : Int, green? : Int, blue? : Int, force? : Bool) -> CameraFadeOptions

#
CameraFollowOptions

pub(all) struct CameraFollowOptions {
lerp_x : Double
lerp_y : Double
offset_x : Double
offset_y : Double
deadzone_width : Double
deadzone_height : Double
} derive(Eq,
Debug
)

#
CameraFollowOptions::is_valid

fn CameraFollowOptions::is_valid(self : CameraFollowOptions) -> Bool

#
CameraFollowOptions::new

fn CameraFollowOptions::new(lerp_x? : Double, lerp_y? : Double, offset_x? : Double, offset_y? : Double, deadzone_width? : Double, deadzone_height? : Double) -> CameraFollowOptions

#
CameraPanOptions

pub(all) struct CameraPanOptions {
target : Point2
duration_ms : Int
ease : EaseKind
force : Bool
} derive(Eq,
Debug
)

#
CameraPanOptions::is_valid

fn CameraPanOptions::is_valid(self : CameraPanOptions) -> Bool

#
CameraPanOptions::new

fn CameraPanOptions::new(target : Point2, duration_ms? : Int, ease? : EaseKind, force? : Bool) -> CameraPanOptions

#
CameraShakeOptions

pub(all) struct CameraShakeOptions {
duration_ms : Int
intensity : Double
force : Bool
} derive(Eq,
Debug
)

#
CameraShakeOptions::is_valid

fn CameraShakeOptions::is_valid(self : CameraShakeOptions) -> Bool

#
CameraShakeOptions::new

fn CameraShakeOptions::new(duration_ms? : Int, intensity? : Double, force? : Bool) -> CameraShakeOptions

#
CameraViewport

pub(all) struct CameraViewport {
x : Int
y : Int
width : Int
height : Int
} derive(Eq,
Debug
)

#
CameraViewport::is_valid

fn CameraViewport::is_valid(self : CameraViewport) -> Bool

#
CameraViewport::new

fn CameraViewport::new(x : Int, y : Int, width : Int, height : Int) -> CameraViewport

#
CameraViewport::size

fn CameraViewport::size(self : CameraViewport) -> Size2

#
CameraZoomOptions

pub(all) struct CameraZoomOptions {
zoom : Double
duration_ms : Int
ease : EaseKind
} derive(Eq,
Debug
)

#
CameraZoomOptions::is_valid

fn CameraZoomOptions::is_valid(self : CameraZoomOptions) -> Bool

#
CameraZoomOptions::new

fn CameraZoomOptions::new(zoom : Double, duration_ms? : Int, ease? : EaseKind) -> CameraZoomOptions

#
CanvasExpectation

pub(all) struct CanvasExpectation {
min_width : Int
min_height : Int
allow_mobile_fit : Bool
require_non_blank : Bool
} derive(Eq,
Debug
)

#
CanvasExpectation::is_valid

fn CanvasExpectation::is_valid(self : CanvasExpectation) -> Bool

#
CanvasExpectation::new

fn CanvasExpectation::new(min_width? : Int, min_height? : Int, allow_mobile_fit? : Bool, require_non_blank? : Bool) -> CanvasExpectation

#
Collider

#external
pub type Collider

A Phaser collider or overlap handle.

#
CssColor

pub(all) struct CssColor {
value : String
} derive(Eq,
Debug
)

Phaser-compatible color literal stored as a CSS string.

#
CssColor::as_string

fn CssColor::as_string(self : CssColor) -> String

#
CssColor::black

fn CssColor::black() -> CssColor

#
CssColor::is_valid

fn CssColor::is_valid(self : CssColor) -> Bool

#
CssColor::new

fn CssColor::new(value : String) -> CssColor

#
CssColor::white

fn CssColor::white() -> CssColor

#
CursorDirection

pub(all) enum CursorDirection {
Left
Right
Up
Down
} derive(Eq,
Debug
)

Cursor-key direction names used in docs and tests.

#
CursorDirection::to_key_name

fn CursorDirection::to_key_name(self : CursorDirection) -> String

Stable string name for a cursor direction.

#
CursorKeys

#external
pub type CursorKeys

A Phaser cursor key bundle.

#
CursorKeys::key

fn CursorKeys::key(self : CursorKeys, direction : CursorDirection) -> Key

Returns a single key from a cursor-key bundle.

#
DisplayObjectOptions

pub(all) struct DisplayObjectOptions {
position : Point2
origin : OriginPoint
scale_x : Double
scale_y : Double
rotation : Double
alpha : Double
depth : Int
visible : Bool
active : Bool
} derive(Eq,
Debug
)

#
DisplayObjectOptions::hidden

#
DisplayObjectOptions::is_valid

fn DisplayObjectOptions::is_valid(self : DisplayObjectOptions) -> Bool

#
DisplayObjectOptions::new

fn DisplayObjectOptions::new(position? : Point2, origin? : OriginPoint, scale_x? : Double, scale_y? : Double, rotation? : Double, alpha? : Double, depth? : Int, visible? : Bool, active? : Bool) -> DisplayObjectOptions

#
DisplayOrigin

pub(all) enum DisplayOrigin {
OriginTopLeft
OriginCenter
OriginBottomCenter
OriginCustom
} derive(Eq,
Debug
)

#
DisplayOrigin::label

fn DisplayOrigin::label(self : DisplayOrigin) -> String

#
DurationMs

pub(all) struct DurationMs {
value : Int
} derive(Eq,
Debug
)

Millisecond duration passed to Phaser tweens, camera effects, and audio fades.

#
DurationMs::is_positive

fn DurationMs::is_positive(self : DurationMs) -> Bool

#
DurationMs::is_valid

fn DurationMs::is_valid(self : DurationMs) -> Bool

#
DurationMs::max

fn DurationMs::max(self : DurationMs, other : DurationMs) -> DurationMs

#
DurationMs::new

fn DurationMs::new(value : Int) -> DurationMs

#
DurationMs::plus

fn DurationMs::plus(self : DurationMs, other : DurationMs) -> DurationMs

#
DurationMs::seconds

fn DurationMs::seconds(seconds : Int) -> DurationMs

#
DurationMs::zero

fn DurationMs::zero() -> DurationMs

#
EaseKind

pub(all) enum EaseKind {
EaseLinear
EaseQuadIn
EaseQuadOut
EaseQuadInOut
EaseCubicIn
EaseCubicOut
EaseSineInOut
EaseBackOut
EaseBounceOut
} derive(Eq,
Debug
)

#
EaseKind::to_phaser_name

fn EaseKind::to_phaser_name(self : EaseKind) -> String

#
ErrorPathExpectation

pub(all) struct ErrorPathExpectation {
kind : ErrorPathKind
operation : String
expected_message : String
} derive(Eq,
Debug
)

#
ErrorPathExpectation::is_valid

fn ErrorPathExpectation::is_valid(self : ErrorPathExpectation) -> Bool

#
ErrorPathExpectation::new

fn ErrorPathExpectation::new(kind : ErrorPathKind, operation : String, expected_message : String) -> ErrorPathExpectation

#
ErrorPathKind

pub(all) enum ErrorPathKind {
ErrorMissingPhaser
ErrorInvalidConfig
ErrorMissingAsset
ErrorBadAnimation
ErrorAudioNotUnlocked
ErrorTilemapLayerMissing
} derive(Eq,
Debug
)

#
ErrorPathKind::label

fn ErrorPathKind::label(self : ErrorPathKind) -> String

#
FeatureSupport

pub(all) struct FeatureSupport {
feature : RuntimeFeature
supported : Bool
notes : String
} derive(Eq,
Debug
)

#
FeatureSupport::is_complete

fn FeatureSupport::is_complete(self : FeatureSupport) -> Bool

#
FeatureSupport::new

fn FeatureSupport::new(feature : RuntimeFeature, supported : Bool, notes? : String) -> FeatureSupport

#
FfiCallRecord

pub(all) struct FfiCallRecord {
feature : RuntimeFeature
operation : String
success : Bool
failure_code : String
} derive(Eq,
Debug
)

#
FfiCallRecord::failed

fn FfiCallRecord::failed(self : FfiCallRecord) -> Bool

#
FfiCallRecord::is_valid

fn FfiCallRecord::is_valid(self : FfiCallRecord) -> Bool

#
FfiCallRecord::new

fn FfiCallRecord::new(feature : RuntimeFeature, operation : String, success : Bool, failure_code? : String) -> FfiCallRecord

#
FfiFailureKind

pub(all) enum FfiFailureKind {
FfiMissingPhaser
FfiMissingPlugin
FfiInvalidAsset
FfiInvalidConfig
FfiRuntimeException
} derive(Eq,
Debug
)

#
FfiFailureKind::code

fn FfiFailureKind::code(self : FfiFailureKind) -> String

#
FrameRange

pub(all) struct FrameRange {
start : Int
end : Int
} derive(Eq,
Debug
)

#
FrameRange::count

fn FrameRange::count(self : FrameRange) -> Int

#
FrameRange::is_valid

fn FrameRange::is_valid(self : FrameRange) -> Bool

#
FrameRange::new

fn FrameRange::new(start : Int, end : Int) -> FrameRange

#
FrameRange::single

fn FrameRange::single(index : Int) -> FrameRange

#
Game

#external
pub type Game

A Phaser.Game handle.

#
Game::create

fn Game::create(config : GameConfig, preload : (Scene) -> Unit, create : (Scene) -> Unit, update : (Scene) -> Unit) -> Game

Creates a Phaser game from MoonBit callbacks.

#
Game::destroy

fn Game::destroy(self : Game) -> Unit

Destroys the Phaser game and removes its canvas.

#
GameAction

pub(all) enum GameAction {
ActionMoveLeft
ActionMoveRight
ActionJump
ActionInteract
ActionPause
ActionRestart
} derive(Eq,
Debug
)

#
GameAction::label

fn GameAction::label(self : GameAction) -> String

#
GameConfig

pub(all) struct GameConfig {
parent : String
width : Int
height : Int
background : String
gravity_y : Int
debug : Bool
} derive(Eq,
Debug
)

Phaser game configuration supported by MoonPhaserKit v1.

The binding intentionally keeps this small: it targets one common 2D web game path, not every Phaser option.

#
GameConfig::is_valid

fn GameConfig::is_valid(self : GameConfig) -> Bool

Returns true when the configuration is suitable for a Phaser canvas.

#
GameConfig::new

fn GameConfig::new(parent? : String, width? : Int, height? : Int, background? : String, gravity_y? : Int, debug? : Bool) -> GameConfig

Creates a default 800x450 Arcade Physics game configuration.

#
ImageAsset

pub(all) struct ImageAsset {
key : String
path : String
} derive(Eq,
Debug
)

Named asset loaded through Scene::load_image.

#
ImageAsset::is_valid

fn ImageAsset::is_valid(self : ImageAsset) -> Bool

Returns true when the asset has a non-empty key and path.

#
ImageAsset::new

fn ImageAsset::new(key : String, path : String) -> ImageAsset

Creates an image asset descriptor.

#
IntegrationChecklist

pub(all) struct IntegrationChecklist {
has_moonbit : Bool
has_node : Bool
has_phaser : Bool
exposes_global_phaser : Bool
builds_generated_js : Bool
imports_generated_js : Bool
smoke_test_passes : Bool
} derive(Eq,
Debug
)

#
IntegrationChecklist::complete

#
IntegrationChecklist::is_demo_ready

fn IntegrationChecklist::is_demo_ready(self : IntegrationChecklist) -> Bool

#
IntegrationChecklist::is_release_ready

fn IntegrationChecklist::is_release_ready(self : IntegrationChecklist) -> Bool

#
IntegrationChecklist::new

fn IntegrationChecklist::new(has_moonbit? : Bool, has_node? : Bool, has_phaser? : Bool, exposes_global_phaser? : Bool, builds_generated_js? : Bool, imports_generated_js? : Bool, smoke_test_passes? : Bool) -> IntegrationChecklist

#
IntegrationStep

pub(all) struct IntegrationStep {
kind : IntegrationStepKind
title : String
required_for_demo : Bool
required_for_package : Bool
} derive(Eq,
Debug
)

#
IntegrationStep::for_package_publish

fn IntegrationStep::for_package_publish() -> IntegrationStep

#
IntegrationStep::is_valid

fn IntegrationStep::is_valid(self : IntegrationStep) -> Bool

#
IntegrationStep::new

fn IntegrationStep::new(kind : IntegrationStepKind, title : String, required_for_demo? : Bool, required_for_package? : Bool) -> IntegrationStep

#
IntegrationStepKind

pub(all) enum IntegrationStepKind {
IntegrationInstallMoonBit
IntegrationInstallNode
IntegrationInstallPhaser
IntegrationExposeGlobalPhaser
IntegrationBuildMoonBitJs
IntegrationImportGeneratedJs
IntegrationRunSmokeTest
IntegrationPublishMooncakes
} derive(Eq,
Debug
)

#
IntegrationStepKind::label

fn IntegrationStepKind::label(self : IntegrationStepKind) -> String

#
InteractionScenarioSummary

pub(all) struct InteractionScenarioSummary {
name : String
step_count : Int
covers_keyboard : Bool
covers_pointer : Bool
covers_collision : Bool
covers_audio : Bool
covers_camera : Bool
} derive(Eq,
Debug
)

#
InteractionScenarioSummary::coverage_score

fn InteractionScenarioSummary::coverage_score(self : InteractionScenarioSummary) -> Int

#
InteractionScenarioSummary::is_valid

#
InteractionScenarioSummary::new

fn InteractionScenarioSummary::new(name : String, step_count : Int, covers_keyboard? : Bool, covers_pointer? : Bool, covers_collision? : Bool, covers_audio? : Bool, covers_camera? : Bool) -> InteractionScenarioSummary

#
InteractionStep

pub(all) struct InteractionStep {
kind : InteractionStepKind
value : String
point : Point2
duration_ms : Int
} derive(Eq,
Debug
)

#
InteractionStep::is_valid

fn InteractionStep::is_valid(self : InteractionStep) -> Bool

#
InteractionStep::new

fn InteractionStep::new(kind : InteractionStepKind, value? : String, point? : Point2, duration_ms? : Int) -> InteractionStep

#
InteractionStep::press_key

fn InteractionStep::press_key(key : String) -> InteractionStep

#
InteractionStep::tap

#
InteractionStep::wait

fn InteractionStep::wait(duration_ms : Int) -> InteractionStep

#
InteractionStepKind

pub(all) enum InteractionStepKind {
StepWait
StepPressKey
StepReleaseKey
StepTap
StepDrag
StepAssertCanvas
StepAssertText
StepAssertNoErrors
} derive(Eq,
Debug
)

#
InteractionStepKind::label

fn InteractionStepKind::label(self : InteractionStepKind) -> String

#
Key

#external
pub type Key

A Phaser keyboard key handle.

#
Key::is_down

fn Key::is_down(self : Key) -> Bool

Returns true while the key is held down.

#
Key::is_up

fn Key::is_up(self : Key) -> Bool

Returns true while the key is released.

#
KeyBinding

pub(all) struct KeyBinding {
action : GameAction
key_code : String
} derive(Eq,
Debug
)

#
KeyBinding::is_valid

fn KeyBinding::is_valid(self : KeyBinding) -> Bool

#
KeyBinding::new

fn KeyBinding::new(action : GameAction, key_code : String) -> KeyBinding

#
MoonBitBackend

pub(all) enum MoonBitBackend {
BackendJavaScript
BackendWasm
BackendNative
} derive(Eq,
Debug
)

#
MoonBitBackend::is_supported

fn MoonBitBackend::is_supported(self : MoonBitBackend) -> Bool

#
MoonBitBackend::label

fn MoonBitBackend::label(self : MoonBitBackend) -> String

#
ObjectLifecycleState

pub(all) enum ObjectLifecycleState {
ObjectCreated
ObjectActive
ObjectPaused
ObjectDestroyed
} derive(Eq,
Debug
)

#
ObjectLifecycleState::can_destroy

fn ObjectLifecycleState::can_destroy(self : ObjectLifecycleState) -> Bool

#
ObjectLifecycleState::can_update

fn ObjectLifecycleState::can_update(self : ObjectLifecycleState) -> Bool

#
OriginPoint

pub(all) struct OriginPoint {
kind : DisplayOrigin
x : Double
y : Double
} derive(Eq,
Debug
)

#
OriginPoint::center

fn OriginPoint::center() -> OriginPoint

#
OriginPoint::custom

fn OriginPoint::custom(x : Double, y : Double) -> OriginPoint

#
OriginPoint::is_valid

fn OriginPoint::is_valid(self : OriginPoint) -> Bool

#
OriginPoint::top_left

fn OriginPoint::top_left() -> OriginPoint

#
PackagePublicationState

pub(all) enum PackagePublicationState {
PackageUnpublished
PackagePendingAccount
PackagePublished
} derive(Eq,
Debug
)

#
PackagePublicationState::label

#
PackagePublicationState::matches_readme

fn PackagePublicationState::matches_readme(self : PackagePublicationState) -> Bool

#
PhaserVersion

pub(all) struct PhaserVersion {
major : Int
minor : Int
patch : Int
} derive(Eq,
Debug
)

#
PhaserVersion::is_phaser3

fn PhaserVersion::is_phaser3(self : PhaserVersion) -> Bool

#
PhaserVersion::is_supported

fn PhaserVersion::is_supported(self : PhaserVersion) -> Bool

#
PhaserVersion::is_valid

fn PhaserVersion::is_valid(self : PhaserVersion) -> Bool

#
PhaserVersion::new

fn PhaserVersion::new(major : Int, minor : Int, patch : Int) -> PhaserVersion

#
PhaserVersion::pinned

#
PhaserVersion::to_string

fn PhaserVersion::to_string(self : PhaserVersion) -> String

#
PhysicsMaterial

pub(all) struct PhysicsMaterial {
kind : PhysicsMaterialKind
bounce_x : Double
bounce_y : Double
gravity_y : Double
immovable : Bool
sensor : Bool
} derive(Eq,
Debug
)

#
PhysicsMaterial::is_valid

fn PhysicsMaterial::is_valid(self : PhysicsMaterial) -> Bool

#
PhysicsMaterial::new

fn PhysicsMaterial::new(kind? : PhysicsMaterialKind, bounce_x? : Double, bounce_y? : Double, gravity_y? : Double, immovable? : Bool, sensor? : Bool) -> PhysicsMaterial

#
PhysicsMaterial::pickup

#
PhysicsMaterial::platform

#
PhysicsMaterial::to_sprite_options

fn PhysicsMaterial::to_sprite_options(self : PhysicsMaterial) -> SpriteOptions

#
PhysicsMaterialKind

pub(all) enum PhysicsMaterialKind {
MaterialDefault
MaterialBouncy
MaterialIce
MaterialHeavy
MaterialSensor
} derive(Eq,
Debug
)

#
PhysicsMaterialKind::label

fn PhysicsMaterialKind::label(self : PhysicsMaterialKind) -> String

#
Point2

pub(all) struct Point2 {
x : Double
y : Double
} derive(Eq,
Debug
)

A 2D point in scene or camera coordinates.

#
Point2::distance_squared_to

fn Point2::distance_squared_to(self : Point2, other : Point2) -> Double

#
Point2::new

fn Point2::new(x : Double, y : Double) -> Point2

#
Point2::scale

fn Point2::scale(self : Point2, factor : Double) -> Point2

#
Point2::translate

fn Point2::translate(self : Point2, delta : Point2) -> Point2

#
Point2::with_x

fn Point2::with_x(self : Point2, x : Double) -> Point2

#
Point2::with_y

fn Point2::with_y(self : Point2, y : Double) -> Point2

#
Point2::zero

fn Point2::zero() -> Point2

#
Pointer

#external
pub type Pointer

A Phaser input pointer handle.

#
Pointer::is_down

fn Pointer::is_down(self : Pointer) -> Bool

#
Pointer::just_down

fn Pointer::just_down(self : Pointer) -> Bool

#
Pointer::world_x

fn Pointer::world_x(self : Pointer) -> Double

#
Pointer::world_y

fn Pointer::world_y(self : Pointer) -> Double

#
Pointer::x

fn Pointer::x(self : Pointer) -> Double

#
Pointer::y

fn Pointer::y(self : Pointer) -> Double

#
PointerButton

pub(all) enum PointerButton {
PointerPrimary
PointerMiddle
PointerSecondary
PointerBack
PointerForward
} derive(Eq,
Debug
)

#
PointerButton::button_index

fn PointerButton::button_index(self : PointerButton) -> Int

#
PointerSnapshot

pub(all) struct PointerSnapshot {
id : Int
position : Point2
world_position : Point2
is_down : Bool
just_down : Bool
button : PointerButton
} derive(Eq,
Debug
)

#
PointerSnapshot::is_valid

fn PointerSnapshot::is_valid(self : PointerSnapshot) -> Bool

#
PointerSnapshot::new

fn PointerSnapshot::new(id : Int, position : Point2, world_position : Point2, is_down : Bool, just_down : Bool, button? : PointerButton) -> PointerSnapshot

#
PointerSnapshot::screen_x

fn PointerSnapshot::screen_x(self : PointerSnapshot) -> Double

#
PointerSnapshot::screen_y

fn PointerSnapshot::screen_y(self : PointerSnapshot) -> Double

#
Rect

pub(all) struct Rect {
x : Double
y : Double
width : Double
height : Double
} derive(Eq,
Debug
)

Axis-aligned rectangle for touch zones, camera bounds, and map regions.

#
Rect::bottom

fn Rect::bottom(self : Rect) -> Double

#
Rect::center

fn Rect::center(self : Rect) -> Point2

#
Rect::contains

fn Rect::contains(self : Rect, point : Point2) -> Bool

#
Rect::from_size

fn Rect::from_size(size : Size2) -> Rect

#
Rect::inflate

fn Rect::inflate(self : Rect, amount : Double) -> Rect

#
Rect::intersects

fn Rect::intersects(self : Rect, other : Rect) -> Bool

#
Rect::is_valid

fn Rect::is_valid(self : Rect) -> Bool

#
Rect::left

fn Rect::left(self : Rect) -> Double

#
Rect::move_to

fn Rect::move_to(self : Rect, point : Point2) -> Rect

#
Rect::new

fn Rect::new(x : Double, y : Double, width : Double, height : Double) -> Rect

#
Rect::right

fn Rect::right(self : Rect) -> Double

#
Rect::top

fn Rect::top(self : Rect) -> Double

#
Rect::translate

fn Rect::translate(self : Rect, delta : Point2) -> Rect

#
RuntimeCompatibility

pub(all) struct RuntimeCompatibility {
backend : MoonBitBackend
phaser : PhaserVersion
browser : BrowserTarget
requires_global_phaser : Bool
} derive(Eq,
Debug
)

#
RuntimeCompatibility::is_supported

fn RuntimeCompatibility::is_supported(self : RuntimeCompatibility) -> Bool

#
RuntimeCompatibility::new

fn RuntimeCompatibility::new(backend? : MoonBitBackend, phaser? : PhaserVersion, browser? : BrowserTarget, requires_global_phaser? : Bool) -> RuntimeCompatibility

#
RuntimeCompatibility::support_summary

fn RuntimeCompatibility::support_summary(self : RuntimeCompatibility) -> String

#
RuntimeFeature

pub(all) enum RuntimeFeature {
FeatureGame
FeatureScene
FeatureSprite
FeaturePhysics
FeatureAnimation
FeatureAudio
FeatureCamera
FeatureTilemap
FeaturePointer
} derive(Eq,
Debug
)

#
RuntimeFeature::label

fn RuntimeFeature::label(self : RuntimeFeature) -> String

#
Scene

#external
pub type Scene

A Phaser.Scene handle.

#
Scene::active_pointer

fn Scene::active_pointer(self : Scene) -> Pointer

#
Scene::add_collider

fn Scene::add_collider(self : Scene, a : Sprite, b : Sprite) -> Collider

Adds a collider between two sprites.

#
Scene::add_key

fn Scene::add_key(self : Scene, key_code : String) -> Key

Adds a keyboard key by Phaser key code, such as "SPACE" or "W".

#
Scene::add_overlap

fn Scene::add_overlap(self : Scene, a : Sprite, b : Sprite, callback : (Sprite, Sprite) -> Unit) -> Collider

Adds an overlap callback between two sprites.

#
Scene::add_sound

fn Scene::add_sound(self : Scene, key : String, options? : SoundOptions) -> Sound

Adds a loaded audio asset to the scene sound manager.

#
Scene::add_sprite

fn Scene::add_sprite(self : Scene, x : Double, y : Double, key : String) -> Sprite

Adds an Arcade Physics sprite to the scene.

#
Scene::add_static_sprite

fn Scene::add_static_sprite(self : Scene, x : Double, y : Double, key : String) -> Sprite

Adds an immovable static Arcade Physics sprite to the scene.

#
Scene::add_text

fn Scene::add_text(self : Scene, x : Double, y : Double, value : String, size? : Int, color? : String) -> Text

Adds text to the scene.

#
Scene::add_text_styled

fn Scene::add_text_styled(self : Scene, x : Double, y : Double, value : String, style? : TextStyle) -> Text

Adds styled text to the scene.

#
Scene::add_timer_event

fn Scene::add_timer_event(self : Scene, config : TimerEventConfig, callback : () -> Unit) -> TimerEvent

#
Scene::create_animation

fn Scene::create_animation(self : Scene, config : AnimationConfig) -> Unit

Creates a frame-number based animation.

#
Scene::cursor_keys

fn Scene::cursor_keys(self : Scene) -> CursorKeys

Creates Phaser cursor keys for keyboard control.

#
Scene::delayed_call

fn Scene::delayed_call(self : Scene, delay : DurationMs, callback : () -> Unit) -> TimerEvent

#
Scene::is_scene_active

fn Scene::is_scene_active(self : Scene, key : String) -> Bool

#
Scene::launch_scene

fn Scene::launch_scene(self : Scene, key : String) -> Unit

#
Scene::load_atlas

fn Scene::load_atlas(self : Scene, asset : TextureAtlasAsset) -> Unit

Loads a texture atlas.

#
Scene::load_audio

fn Scene::load_audio(self : Scene, asset : AudioAsset) -> Unit

Loads an audio asset.

#
Scene::load_image

fn Scene::load_image(self : Scene, asset : ImageAsset) -> Unit

Loads an image asset during the scene preload callback.

#
Scene::load_spritesheet

fn Scene::load_spritesheet(self : Scene, asset : SpriteSheetAsset) -> Unit

Loads a spritesheet for frame animations.

#
Scene::load_tilemap_json

fn Scene::load_tilemap_json(self : Scene, asset : TilemapJsonAsset) -> Unit

Loads a Tiled JSON tilemap.

#
Scene::main_camera

fn Scene::main_camera(self : Scene) -> Camera

#
Scene::make_tilemap

fn Scene::make_tilemap(self : Scene, config : TilemapConfig) -> Tilemap

#
Scene::on_pointer_down

fn Scene::on_pointer_down(self : Scene, callback : (Pointer) -> Unit) -> Unit

#
Scene::on_pointer_move

fn Scene::on_pointer_move(self : Scene, callback : (Pointer) -> Unit) -> Unit

#
Scene::on_pointer_up

fn Scene::on_pointer_up(self : Scene, callback : (Pointer) -> Unit) -> Unit

#
Scene::pause_scene

fn Scene::pause_scene(self : Scene, key : String) -> Unit

#
Scene::restart

fn Scene::restart(self : Scene) -> Unit

Restarts the current scene.

#
Scene::resume_scene

fn Scene::resume_scene(self : Scene, key : String) -> Unit

#
Scene::sleep_scene

fn Scene::sleep_scene(self : Scene, key : String) -> Unit

#
Scene::start_scene

fn Scene::start_scene(self : Scene, key : String) -> Unit

#
Scene::stop_scene

fn Scene::stop_scene(self : Scene, key : String) -> Unit

#
Scene::wake_scene

fn Scene::wake_scene(self : Scene, key : String) -> Unit

#
SceneControlAction

pub(all) enum SceneControlAction {
SceneStart
SceneLaunch
ScenePause
SceneResume
SceneStop
SceneSleep
SceneWake
} derive(Eq,
Debug
)

#
SceneControlAction::keeps_current_scene

fn SceneControlAction::keeps_current_scene(self : SceneControlAction) -> Bool

#
SceneControlAction::label

fn SceneControlAction::label(self : SceneControlAction) -> String

#
SceneControlCommand

pub(all) struct SceneControlCommand {
action : SceneControlAction
target_scene : String
} derive(Eq,
Debug
)

#
SceneControlCommand::is_transition

fn SceneControlCommand::is_transition(self : SceneControlCommand) -> Bool

#
SceneControlCommand::is_valid

fn SceneControlCommand::is_valid(self : SceneControlCommand) -> Bool

#
SceneControlCommand::new

fn SceneControlCommand::new(action : SceneControlAction, target_scene : String) -> SceneControlCommand

#
SceneLayerConfig

pub(all) struct SceneLayerConfig {
kind : SceneLayerKind
name : String
depth : Int
scroll_factor_x : Double
scroll_factor_y : Double
visible : Bool
} derive(Eq,
Debug
)

#
SceneLayerConfig::is_valid

fn SceneLayerConfig::is_valid(self : SceneLayerConfig) -> Bool

#
SceneLayerConfig::new

fn SceneLayerConfig::new(kind : SceneLayerKind, name? : String, depth? : Int, scroll_factor_x? : Double, scroll_factor_y? : Double, visible? : Bool) -> SceneLayerConfig

#
SceneLayerKind

pub(all) enum SceneLayerKind {
LayerBackground
LayerWorld
LayerActors
LayerEffects
LayerUi
} derive(Eq,
Debug
)

#
SceneLayerKind::default_depth

fn SceneLayerKind::default_depth(self : SceneLayerKind) -> Int

#
SceneLayerKind::label

fn SceneLayerKind::label(self : SceneLayerKind) -> String

#
SceneTransition

pub(all) struct SceneTransition {
from_scene : String
to_scene : String
fade : CameraFadeOptions
restart_current : Bool
} derive(Eq,
Debug
)

#
SceneTransition::is_valid

fn SceneTransition::is_valid(self : SceneTransition) -> Bool

#
SceneTransition::new

fn SceneTransition::new(from_scene : String, to_scene : String, fade? : CameraFadeOptions, restart_current? : Bool) -> SceneTransition

#
Size2

pub(all) struct Size2 {
width : Int
height : Int
} derive(Eq,
Debug
)

A non-negative size used by cameras, tilemaps, and viewports.

#
Size2::area

fn Size2::area(self : Size2) -> Int

#
Size2::is_landscape

fn Size2::is_landscape(self : Size2) -> Bool

#
Size2::is_portrait

fn Size2::is_portrait(self : Size2) -> Bool

#
Size2::is_valid

fn Size2::is_valid(self : Size2) -> Bool

#
Size2::new

fn Size2::new(width : Int, height : Int) -> Size2

#
Size2::with_height

fn Size2::with_height(self : Size2, height : Int) -> Size2

#
Size2::with_width

fn Size2::with_width(self : Size2, width : Int) -> Size2

#
Sound

#external
pub type Sound

A Phaser.Sound.BaseSound handle.

#
Sound::destroy

fn Sound::destroy(self : Sound) -> Unit

#
Sound::pause

fn Sound::pause(self : Sound) -> Unit

#
Sound::play

fn Sound::play(self : Sound) -> Unit

#
Sound::resume_playback

fn Sound::resume_playback(self : Sound) -> Unit

#
Sound::set_mute

fn Sound::set_mute(self : Sound, muted : Bool) -> Unit

#
Sound::set_volume

fn Sound::set_volume(self : Sound, volume : Double) -> Unit

#
Sound::stop

fn Sound::stop(self : Sound) -> Unit

#
SoundLoopMode

pub(all) enum SoundLoopMode {
SoundPlayOnce
SoundLoop
} derive(Eq,
Debug
)

#
SoundLoopMode::as_bool

fn SoundLoopMode::as_bool(self : SoundLoopMode) -> Bool

#
SoundMarker

pub(all) struct SoundMarker {
name : String
start : Double
duration : Double
config : SoundOptions
} derive(Eq,
Debug
)

#
SoundMarker::is_valid

fn SoundMarker::is_valid(self : SoundMarker) -> Bool

#
SoundMarker::new

fn SoundMarker::new(name : String, start : Double, duration : Double, config? : SoundOptions) -> SoundMarker

#
SoundOptions

pub(all) struct SoundOptions {
volume : Double
rate : Double
detune : Int
seek : Double
delay_ms : Int
loop_mode : SoundLoopMode
} derive(Eq,
Debug
)

#
SoundOptions::is_valid

fn SoundOptions::is_valid(self : SoundOptions) -> Bool

#
SoundOptions::muted

fn SoundOptions::muted() -> SoundOptions

#
SoundOptions::new

fn SoundOptions::new(volume? : Double, rate? : Double, detune? : Int, seek? : Double, delay_ms? : Int, loop_mode? : SoundLoopMode) -> SoundOptions

#
SoundOptions::should_loop

fn SoundOptions::should_loop(self : SoundOptions) -> Bool

#
SpawnSpec

pub(all) struct SpawnSpec {
key : String
position : Point2
display : DisplayObjectOptions
physics : PhysicsMaterial
layer : SceneLayerKind
} derive(Eq,
Debug
)

#
SpawnSpec::is_valid

fn SpawnSpec::is_valid(self : SpawnSpec) -> Bool

#
SpawnSpec::new

fn SpawnSpec::new(key : String, position : Point2, display? : DisplayObjectOptions, physics? : PhysicsMaterial, layer? : SceneLayerKind) -> SpawnSpec

#
SpawnSpec::with_layer

fn SpawnSpec::with_layer(self : SpawnSpec, layer : SceneLayerKind) -> SpawnSpec

#
Sprite

#external
pub type Sprite

A Phaser.Physics.Arcade.Sprite handle.

#
Sprite::apply_display_options

fn Sprite::apply_display_options(self : Sprite, options : DisplayObjectOptions) -> Unit

Applies display options that are shared by sprites and UI specs.

#
Sprite::apply_options

fn Sprite::apply_options(self : Sprite, options : SpriteOptions) -> Unit

Applies reusable sprite options to an Arcade sprite.

#
Sprite::body

fn Sprite::body(self : Sprite) -> ArcadeBody

Returns the Arcade Physics body attached to a sprite.

#
Sprite::destroy

fn Sprite::destroy(self : Sprite) -> Unit

Destroys a sprite.

#
Sprite::play_animation

fn Sprite::play_animation(self : Sprite, key : String, ignore_if_playing? : Bool) -> Unit

Plays a previously created animation.

#
Sprite::set_active

fn Sprite::set_active(self : Sprite, active : Bool) -> Unit

Activates or deactivates a sprite.

#
Sprite::set_alpha

fn Sprite::set_alpha(self : Sprite, alpha : Double) -> Unit

Sets sprite alpha.

#
Sprite::set_depth

fn Sprite::set_depth(self : Sprite, depth : Int) -> Unit

Sets sprite render depth.

#
Sprite::set_flip_x

fn Sprite::set_flip_x(self : Sprite, flip : Bool) -> Unit

Mirrors a sprite horizontally.

#
Sprite::set_origin

fn Sprite::set_origin(self : Sprite, origin : OriginPoint) -> Unit

Sets sprite origin in normalized coordinates.

#
Sprite::set_position

fn Sprite::set_position(self : Sprite, point : Point2) -> Unit

Sets sprite position.

#
Sprite::set_rotation

fn Sprite::set_rotation(self : Sprite, rotation : Double) -> Unit

Sets sprite rotation in radians.

#
Sprite::set_scale

fn Sprite::set_scale(self : Sprite, scale : Double) -> Unit

Sets a sprite scale.

#
Sprite::set_scale_xy

fn Sprite::set_scale_xy(self : Sprite, x : Double, y : Double) -> Unit

Sets sprite scale independently on both axes.

#
Sprite::set_scroll_factor

fn Sprite::set_scroll_factor(self : Sprite, x : Double, y : Double) -> Unit

Sets how strongly the sprite follows camera scrolling.

#
Sprite::set_texture

fn Sprite::set_texture(self : Sprite, key : String) -> Unit

Switches the sprite texture.

#
Sprite::set_tint

fn Sprite::set_tint(self : Sprite, color : Int) -> Unit

Applies a Phaser tint color, for example 0xffcc00.

#
Sprite::set_visible

fn Sprite::set_visible(self : Sprite, visible : Bool) -> Unit

Shows or hides a sprite.

#
Sprite::stop_animation

fn Sprite::stop_animation(self : Sprite) -> Unit

Stops the current sprite animation.

#
SpriteOptions

pub(all) struct SpriteOptions {
scale : Double
immovable : Bool
collide_world_bounds : Bool
bounce_x : Double
bounce_y : Double
gravity_y : Double
} derive(Eq,
Debug
)

A small immutable sprite setup object used by examples and tests.

#
SpriteOptions::new

fn SpriteOptions::new(scale? : Double, immovable? : Bool, collide_world_bounds? : Bool, bounce_x? : Double, bounce_y? : Double, gravity_y? : Double) -> SpriteOptions

Creates reusable sprite physics options.

#
SpriteSheetAsset

pub(all) struct SpriteSheetAsset {
key : String
path : String
frame_width : Int
frame_height : Int
margin : Int
spacing : Int
} derive(Eq,
Debug
)

Sprite-sheet asset descriptor for frame based animation.

#
SpriteSheetAsset::frame_size

fn SpriteSheetAsset::frame_size(self : SpriteSheetAsset) -> Size2

#
SpriteSheetAsset::is_valid

fn SpriteSheetAsset::is_valid(self : SpriteSheetAsset) -> Bool

#
SpriteSheetAsset::new

fn SpriteSheetAsset::new(key : String, path : String, frame_width : Int, frame_height : Int, margin? : Int, spacing? : Int) -> SpriteSheetAsset

#
SpriteTween

pub(all) struct SpriteTween {
from : Point2
to : Point2
alpha_from : Double
alpha_to : Double
scale_from : Double
scale_to : Double
config : TweenConfig
} derive(Eq,
Debug
)

#
SpriteTween::is_valid

fn SpriteTween::is_valid(self : SpriteTween) -> Bool

#
SpriteTween::new

fn SpriteTween::new(from : Point2, to : Point2, alpha_from? : Double, alpha_to? : Double, scale_from? : Double, scale_to? : Double, config? : TweenConfig) -> SpriteTween

#
SwipeConfig

pub(all) struct SwipeConfig {
threshold : Double
max_duration_ms : Int
} derive(Eq,
Debug
)

#
SwipeConfig::is_valid

fn SwipeConfig::is_valid(self : SwipeConfig) -> Bool

#
SwipeConfig::new

fn SwipeConfig::new(threshold? : Double, max_duration_ms? : Int) -> SwipeConfig

#
SwipeDirection

pub(all) enum SwipeDirection {
SwipeLeft
SwipeRight
SwipeUp
SwipeDown
SwipeNone
} derive(Eq,
Debug
)

#
SwipeDirection::to_key_name

fn SwipeDirection::to_key_name(self : SwipeDirection) -> String

#
SwipeSnapshot

pub(all) struct SwipeSnapshot {
start : Point2
current : Point2
elapsed_ms : Int
config : SwipeConfig
} derive(Eq,
Debug
)

#
SwipeSnapshot::delta

fn SwipeSnapshot::delta(self : SwipeSnapshot) -> Point2

#
SwipeSnapshot::direction

fn SwipeSnapshot::direction(self : SwipeSnapshot) -> SwipeDirection

#
SwipeSnapshot::is_fast_enough

fn SwipeSnapshot::is_fast_enough(self : SwipeSnapshot) -> Bool

#
SwipeSnapshot::is_valid

fn SwipeSnapshot::is_valid(self : SwipeSnapshot) -> Bool

#
SwipeSnapshot::new

fn SwipeSnapshot::new(start : Point2, current : Point2, elapsed_ms : Int, config? : SwipeConfig) -> SwipeSnapshot

#
Text

#external
pub type Text

A Phaser.GameObjects.Text handle.

#
Text::destroy

fn Text::destroy(self : Text) -> Unit

#
Text::set_alpha

fn Text::set_alpha(self : Text, alpha : Double) -> Unit

#
Text::set_depth

fn Text::set_depth(self : Text, depth : Int) -> Unit

#
Text::set_position

fn Text::set_position(self : Text, point : Point2) -> Unit

#
Text::set_scroll_factor

fn Text::set_scroll_factor(self : Text, x : Double, y : Double) -> Unit

#
Text::set_text

fn Text::set_text(self : Text, value : String) -> Unit

Updates a text object's displayed string.

#
Text::set_visible

fn Text::set_visible(self : Text, visible : Bool) -> Unit

#
TextAlign

pub(all) enum TextAlign {
TextAlignLeft
TextAlignCenter
TextAlignRight
} derive(Eq,
Debug
)

#
TextAlign::to_phaser_name

fn TextAlign::to_phaser_name(self : TextAlign) -> String

#
TextStyle

pub(all) struct TextStyle {
font_family : String
font_size : Int
color : String
background_color : String
stroke_color : String
stroke_thickness : Int
align : TextAlign
fixed_width : Int
fixed_height : Int
word_wrap_width : Int
} derive(Eq,
Debug
)

#
TextStyle::dialogue

fn TextStyle::dialogue() -> TextStyle

#
TextStyle::has_background

fn TextStyle::has_background(self : TextStyle) -> Bool

#
TextStyle::has_stroke

fn TextStyle::has_stroke(self : TextStyle) -> Bool

#
TextStyle::is_valid

fn TextStyle::is_valid(self : TextStyle) -> Bool

#
TextStyle::new

fn TextStyle::new(font_family? : String, font_size? : Int, color? : String, background_color? : String, stroke_color? : String, stroke_thickness? : Int, align? : TextAlign, fixed_width? : Int, fixed_height? : Int, word_wrap_width? : Int) -> TextStyle

#
TextStyle::scoreboard

fn TextStyle::scoreboard() -> TextStyle

#
TextStyle::with_color

fn TextStyle::with_color(self : TextStyle, color : String) -> TextStyle

#
TextureAsset

pub(all) struct TextureAsset {
key : String
path : String
} derive(Eq,
Debug
)

Image asset loaded by Phaser's loader.

#
TextureAsset::from_image

fn TextureAsset::from_image(asset : ImageAsset) -> TextureAsset

#
TextureAsset::is_valid

fn TextureAsset::is_valid(self : TextureAsset) -> Bool

#
TextureAsset::new

fn TextureAsset::new(key : String, path : String) -> TextureAsset

#
TextureAtlasAsset

pub(all) struct TextureAtlasAsset {
key : String
texture_path : String
atlas_path : String
} derive(Eq,
Debug
)

Atlas asset descriptor for packed sprite frames.

#
TextureAtlasAsset::is_valid

fn TextureAtlasAsset::is_valid(self : TextureAtlasAsset) -> Bool

#
TextureAtlasAsset::new

fn TextureAtlasAsset::new(key : String, texture_path : String, atlas_path : String) -> TextureAtlasAsset

#
TileCollisionRange

pub(all) struct TileCollisionRange {
start_index : Int
end_index : Int
collides : Bool
} derive(Eq,
Debug
)

#
TileCollisionRange::is_valid

fn TileCollisionRange::is_valid(self : TileCollisionRange) -> Bool

#
TileCollisionRange::new

fn TileCollisionRange::new(start_index : Int, end_index : Int, collides? : Bool) -> TileCollisionRange

#
TileLayer

#external
pub type TileLayer

A Phaser.Tilemaps.TilemapLayer handle.

#
TileLayer::destroy

fn TileLayer::destroy(self : TileLayer) -> Unit

#
TileLayer::set_alpha

fn TileLayer::set_alpha(self : TileLayer, alpha : Double) -> Unit

#
TileLayer::set_collision_between

fn TileLayer::set_collision_between(self : TileLayer, range : TileCollisionRange) -> Unit

#
TileLayer::set_collision_by_property

fn TileLayer::set_collision_by_property(self : TileLayer, matcher : TilePropertyMatcher) -> Unit

#
TileLayer::set_visible

fn TileLayer::set_visible(self : TileLayer, visible : Bool) -> Unit

#
TileLayerConfig

pub(all) struct TileLayerConfig {
layer_name : String
tileset_name : String
x : Double
y : Double
visible : Bool
alpha : Double
} derive(Eq,
Debug
)

#
TileLayerConfig::is_valid

fn TileLayerConfig::is_valid(self : TileLayerConfig) -> Bool

#
TileLayerConfig::new

fn TileLayerConfig::new(layer_name : String, tileset_name : String, x? : Double, y? : Double, visible? : Bool, alpha? : Double) -> TileLayerConfig

#
TileObject

pub(all) struct TileObject {
name : String
object_type : String
position : Point2
size : Size2
} derive(Eq,
Debug
)

#
TileObject::bounds

fn TileObject::bounds(self : TileObject) -> Rect

#
TileObject::is_valid

fn TileObject::is_valid(self : TileObject) -> Bool

#
TileObject::new

fn TileObject::new(name : String, object_type : String, position : Point2, size : Size2) -> TileObject

#
TilePropertyMatcher

pub(all) struct TilePropertyMatcher {
property : String
value : String
collides : Bool
} derive(Eq,
Debug
)

#
TilePropertyMatcher::is_valid

fn TilePropertyMatcher::is_valid(self : TilePropertyMatcher) -> Bool

#
TilePropertyMatcher::new

fn TilePropertyMatcher::new(property : String, value : String, collides? : Bool) -> TilePropertyMatcher

#
TileSpawnPoint

pub(all) struct TileSpawnPoint {
name : String
position : Point2
facing : AnimationDirection
} derive(Eq,
Debug
)

#
TileSpawnPoint::is_valid

fn TileSpawnPoint::is_valid(self : TileSpawnPoint) -> Bool

#
TileSpawnPoint::new

fn TileSpawnPoint::new(name : String, position : Point2, facing? : AnimationDirection) -> TileSpawnPoint

#
Tilemap

#external
pub type Tilemap

A Phaser.Tilemaps.Tilemap handle.

#
Tilemap::add_tileset

fn Tilemap::add_tileset(self : Tilemap, config : TilesetConfig) -> Tileset

#
Tilemap::create_layer

fn Tilemap::create_layer(self : Tilemap, config : TileLayerConfig) -> TileLayer

#
TilemapConfig

pub(all) struct TilemapConfig {
key : String
tile_width : Int
tile_height : Int
width : Int
height : Int
orientation : TilemapOrientation
} derive(Eq,
Debug
)

#
TilemapConfig::is_valid

fn TilemapConfig::is_valid(self : TilemapConfig) -> Bool

#
TilemapConfig::new

fn TilemapConfig::new(key : String, tile_width : Int, tile_height : Int, width? : Int, height? : Int, orientation? : TilemapOrientation) -> TilemapConfig

#
TilemapConfig::tile_size

fn TilemapConfig::tile_size(self : TilemapConfig) -> Size2

#
TilemapJsonAsset

pub(all) struct TilemapJsonAsset {
key : String
path : String
} derive(Eq,
Debug
)

JSON tilemap descriptor loaded through Scene::load_tilemap_json.

#
TilemapJsonAsset::is_valid

fn TilemapJsonAsset::is_valid(self : TilemapJsonAsset) -> Bool

#
TilemapJsonAsset::new

fn TilemapJsonAsset::new(key : String, path : String) -> TilemapJsonAsset

#
TilemapOrientation

pub(all) enum TilemapOrientation {
TilemapOrthogonal
TilemapIsometric
TilemapStaggered
TilemapHexagonal
} derive(Eq,
Debug
)

#
TilemapOrientation::label

fn TilemapOrientation::label(self : TilemapOrientation) -> String

#
Tileset

#external
pub type Tileset

A Phaser.Tilemaps.Tileset handle.

#
TilesetConfig

pub(all) struct TilesetConfig {
name : String
texture_key : String
tile_width : Int
tile_height : Int
margin : Int
spacing : Int
} derive(Eq,
Debug
)

#
TilesetConfig::is_valid

fn TilesetConfig::is_valid(self : TilesetConfig) -> Bool

#
TilesetConfig::new

fn TilesetConfig::new(name : String, texture_key : String, tile_width : Int, tile_height : Int, margin? : Int, spacing? : Int) -> TilesetConfig

#
TimerEvent

#external
pub type TimerEvent

A Phaser.Time.TimerEvent handle.

#
TimerEvent::get_progress

fn TimerEvent::get_progress(self : TimerEvent) -> Double

#
TimerEvent::remove

fn TimerEvent::remove(self : TimerEvent, dispatch_callback? : Bool) -> Unit

#
TimerEventConfig

pub(all) struct TimerEventConfig {
delay_ms : Int
repeat_mode : TimerRepeatMode
repeat_count : Int
start_at_ms : Int
time_scale : Double
paused : Bool
} derive(Eq,
Debug
)

#
TimerEventConfig::fires_once

fn TimerEventConfig::fires_once(self : TimerEventConfig) -> Bool

#
TimerEventConfig::is_valid

fn TimerEventConfig::is_valid(self : TimerEventConfig) -> Bool

#
TimerEventConfig::looping

fn TimerEventConfig::looping(delay_ms : Int) -> TimerEventConfig

#
TimerEventConfig::loops_forever

fn TimerEventConfig::loops_forever(self : TimerEventConfig) -> Bool

#
TimerEventConfig::new

fn TimerEventConfig::new(delay_ms? : Int, repeat_mode? : TimerRepeatMode, repeat_count? : Int, start_at_ms? : Int, time_scale? : Double, paused? : Bool) -> TimerEventConfig

#
TimerEventConfig::once

fn TimerEventConfig::once(delay_ms : Int) -> TimerEventConfig

#
TimerEventConfig::phaser_repeat

fn TimerEventConfig::phaser_repeat(self : TimerEventConfig) -> Int

#
TimerEventConfig::repeat

fn TimerEventConfig::repeat(delay_ms : Int, repeat_count : Int) -> TimerEventConfig

#
TimerRepeatMode

pub(all) enum TimerRepeatMode {
TimerOnce
TimerRepeat
TimerLoop
} derive(Eq,
Debug
)

#
TimerRepeatMode::label

fn TimerRepeatMode::label(self : TimerRepeatMode) -> String

#
TimerRepeatMode::should_loop

fn TimerRepeatMode::should_loop(self : TimerRepeatMode) -> Bool

#
TimerRepeatMode::to_repeat_count

fn TimerRepeatMode::to_repeat_count(self : TimerRepeatMode, repeat_count? : Int) -> Int

#
TouchZone

pub(all) struct TouchZone {
name : String
rect : Rect
enabled : Bool
} derive(Eq,
Debug
)

#
TouchZone::contains

fn TouchZone::contains(self : TouchZone, snapshot : PointerSnapshot) -> Bool

#
TouchZone::disable

fn TouchZone::disable(self : TouchZone) -> TouchZone

#
TouchZone::enable

fn TouchZone::enable(self : TouchZone) -> TouchZone

#
TouchZone::is_valid

fn TouchZone::is_valid(self : TouchZone) -> Bool

#
TouchZone::new

fn TouchZone::new(name : String, rect : Rect, enabled? : Bool) -> TouchZone

#
TweenConfig

pub(all) struct TweenConfig {
duration_ms : Int
delay_ms : Int
ease : EaseKind
yoyo : Bool
repeat_count : Int
} derive(Eq,
Debug
)

#
TweenConfig::is_valid

fn TweenConfig::is_valid(self : TweenConfig) -> Bool

#
TweenConfig::new

fn TweenConfig::new(duration_ms? : Int, delay_ms? : Int, ease? : EaseKind, yoyo? : Bool, repeat_count? : Int) -> TweenConfig

#
ValidationIssue

pub(all) struct ValidationIssue {
severity : ValidationSeverity
code : String
message : String
} derive(Eq,
Debug
)

#
ValidationIssue::is_error

fn ValidationIssue::is_error(self : ValidationIssue) -> Bool

#
ValidationIssue::is_valid

fn ValidationIssue::is_valid(self : ValidationIssue) -> Bool

#
ValidationIssue::new

fn ValidationIssue::new(severity : ValidationSeverity, code : String, message : String) -> ValidationIssue

#
ValidationSeverity

pub(all) enum ValidationSeverity {
SeverityInfo
SeverityWarning
SeverityError
} derive(Eq,
Debug
)

#
ValidationSeverity::is_blocking

fn ValidationSeverity::is_blocking(self : ValidationSeverity) -> Bool

#
ValidationSeverity::label

fn ValidationSeverity::label(self : ValidationSeverity) -> String

#
Velocity

pub(all) struct Velocity {
x : Double
y : Double
} derive(Eq,
Debug
)

Two-dimensional velocity used by sprite and body helpers.

#
Velocity::new

fn Velocity::new(x : Double, y : Double) -> Velocity

Creates a velocity vector.