安装 Steam
登录
|
语言
繁體中文(繁体中文)
日本語(日语)
한국어(韩语)
ไทย(泰语)
български(保加利亚语)
Čeština(捷克语)
Dansk(丹麦语)
Deutsch(德语)
English(英语)
Español-España(西班牙语 - 西班牙)
Español - Latinoamérica(西班牙语 - 拉丁美洲)
Ελληνικά(希腊语)
Français(法语)
Italiano(意大利语)
Bahasa Indonesia(印度尼西亚语)
Magyar(匈牙利语)
Nederlands(荷兰语)
Norsk(挪威语)
Polski(波兰语)
Português(葡萄牙语 - 葡萄牙)
Português-Brasil(葡萄牙语 - 巴西)
Română(罗马尼亚语)
Русский(俄语)
Suomi(芬兰语)
Svenska(瑞典语)
Türkçe(土耳其语)
Tiếng Việt(越南语)
Українська(乌克兰语)
报告翻译问题
This gets super unweildly, so some genius came up with switch, wherein you get this:
Basically, if everything boils down to one outcome that then branches off a bunch of different ways, switch is your boy. That said, GM does seem fine with switch's condition being a statement, so long as that statement has a defined outcome it can refer to:
That said, conditionals like "or" and "and" probably won't work here, because they're only valid when looking for a true or false result, which is where if stamants work out; if statements are strictly boolean, working in "true" or "false" as a whole, while switch is all about basing a decision on a single variable value or result.
I think i am starting to understand.
this was my code I was trying to run. (i no longer need it, but I just want to make sure I understand it)
and it was saying the case # 2 had to be a constant.
would this work instead?
or am I still not understanding something? it's still really fuzzy in my mind right now, but im sure ill catch on sooner or later.
When you put "case" statements in sequence, what you're really getting is this:
Because cases behave that way, any attempt to nest situations ends up actually meaning "if any one of these is the case." Your example would execute x-=4 if the left key was down, the unicode for any pressed key was the same as x, or x was less than 40 and the unicode for a pressed key was 40 as well. Converting that second case to a new switch statement or a quick if branch will work fine (you can logic within logic all you want), but cases just don't work that way.
So basically the switch statement keeps going after the first "true" value, even if the value wasnt the same as the next? like, in your example, if the random number was 5, it would execute case 6 & 9 (if they didnt have breaks in them) even if the random number was 5?
Ok, that question was a little confusing, I will just do an example of what i'm asking:
So in the code above, if the random number happened to be 5, it would create an instance of object 1, then continue onto case 6, create instance of object 2, then continue to case 9 and create object 3 before the switch statement is over?
Thanks