Last active
June 28, 2020 06:52
-
-
Save flushpot1125/77602620792955c52f33ccef125f2d14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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