KaBoom-guide

可通过Guide教程进行入门,记得点击next按键逐步开始

笔记

action 的 tag 用法

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);
    });

action的另一种用法

另一种方式,直接写成 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");
        }
    });

collides来进行碰撞检测

birdy.collides("pipe", () => {
        go("main");
    });

最后更新于