Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
food.actionManager.registerAction(
new ExecuteCodeAction(
{
trigger: ActionManager.OnIntersectionEnterTrigger,//アクション発生のきっかけ。ここではparameterで指定されたものと衝突したら。
parameter: snake,
},
//以下のfunctionは、foodとsnakeが衝突したら実行される
function () {
//パーティクルを発生させる
function () {
var particleSystem = addParticlesToMesh(food, scene);
scene.removeMesh(food);
sleep(250).then(() => {
removeParticlesFromMesh(particleSystem);
let currentScore = incrementScore();
//add new mesh length to snake
let currentSpeed = snakeSpeed;
//snakeが長くなる
snake.scaling.addInPlace(new Vector3(1, 0, 0));
//increase speed
snakeSpeed = currentSpeed * 2;
//新しいフルーツを生成する (UnityでいうInstantiate)
addNom(scene, snake, snakeSpeed);
});
}
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.