[英]How do I make it so that when I have a specific Key press it creates an interupt
[英]How do I code where when I press a key it creates a 50% chance an animation happens?
我正在用 c# 制作一個統一的格斗游戲,我想這樣做,所以當我按下一個鍵 (j) 時,他有 50% 的機會被擊中,有 50% 的機會他阻止它。 阻擋/擊中是動畫,所以當我按下鍵時,他有 50/50 的機會播放每個 animation。
我試過看 yt 視頻,只有戰利品盒和隨機范圍的東西
您可以生成一個隨機的 integer 0
或1
,然后在 if-case 中使用它:
Random rnd = new Random();
int r = rnd.Next(0, 2);
if(r == 0) {
animate1();
} else {
anmimate2();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.