asset addressable PBS surface
This commit is contained in:
@@ -3,14 +3,55 @@ import { Color } from @core:color;
|
||||
import { Log } from @sdk:log;
|
||||
import { Input } from @sdk:input;
|
||||
import { Gfx } from @sdk:gfx;
|
||||
import { Assets } from @sdk:asset;
|
||||
|
||||
declare global loading_handle: int = -1;
|
||||
declare global loading_status: int = -1;
|
||||
declare global frame_counter: int = 0;
|
||||
declare global tile_id: int = 0;
|
||||
declare const MAX_FRAMES: int = 4;
|
||||
|
||||
[Init]
|
||||
fn init() -> void
|
||||
{
|
||||
loading_handle= -1;
|
||||
loading_status = -1;
|
||||
frame_counter = 0;
|
||||
tile_id = 0;
|
||||
}
|
||||
|
||||
[Frame]
|
||||
fn frame() -> void
|
||||
{
|
||||
Gfx.clear(new Color(6577));
|
||||
|
||||
if (loading_handle == -1) {
|
||||
let t = Assets.load(assets.ui.atlas2, 3);
|
||||
if (t.status != 0) {
|
||||
Log.error("load failed");
|
||||
} else {
|
||||
loading_handle = t.loading_handle;
|
||||
Log.info("state: loading");
|
||||
}
|
||||
} else {
|
||||
let s = Assets.status(loading_handle);
|
||||
if (s == 2) {
|
||||
let commit_status = Assets.commit(loading_handle);
|
||||
if (commit_status != 0) {
|
||||
Log.error("commit failed");
|
||||
}
|
||||
} else if (s == 3) {
|
||||
let sprite_status = Gfx.set_sprite(3, 10, 150, 150, 0, 0, true, false, false, 1);
|
||||
if (sprite_status != 0) {
|
||||
Log.error("set_sprite failed");
|
||||
}
|
||||
} else {
|
||||
Log.info("state: waiting");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
let touch = Input.touch();
|
||||
|
||||
if (touch.button().released())
|
||||
@@ -33,10 +74,8 @@ fn frame() -> void
|
||||
}
|
||||
}
|
||||
|
||||
Gfx.clear(new Color(6577));
|
||||
// Gfx.draw_square(touch.x(), touch.y(), 16, 16, new Color(65535), new Color(13271));
|
||||
let sprite_status = Gfx.set_sprite(0, 0, touch.x() - 16, touch.y() + 8, tile_id, 0, true, true, false, 0);
|
||||
let sprite_status2 = Gfx.set_sprite(0, 1, touch.x() + 16, touch.y() + 8, tile_id, 0, true, false, false, 0);
|
||||
Gfx.set_sprite(0, 0, touch.x() - 16, touch.y() + 8, tile_id, 0, true, true, false, 0);
|
||||
Gfx.set_sprite(0, 1, touch.x() + 16, touch.y() + 8, tile_id, 0, true, false, false, 0);
|
||||
|
||||
let a = 10;
|
||||
let b = 15;
|
||||
|
||||
Reference in New Issue
Block a user