KaBoom-guide
we use action("pipe", ...) to give all objects with tag "pipe" something to run every frame 创建action的tag然后给每一个有tag的东西每帧运行 。用 tag 来表示action ,在add() 列表里如果不给component而是给一个字符串 (如"pipe" )就是给这个obj加一个tag,然后可以用全局 action("pipe", () => { 你的action函数 }); 来给每个有 "pipe" 的obj一个action函数
action("pipe", (pipe) => {
pipe.move(-PIPE_SPEED, 0);
});
另一种方式,直接写成 xxx.action(()=>{})
we do this by giving birdy an action to run every frame, to check if its position is out of screen
birdy.action(() => {
if (birdy.pos.y >= height()) {
go("main");
}
});
birdy.collides("pipe", () => {
go("main");
});
最近更新 1yr ago