์ถœ์ฒ˜ :ย http://www.yoyogames.com/blog/40



viewimage.php?id=2abcdd23dad63db0&no=29bcc427b28377a16fb3dab004c86b6f2ced7c20b23a219c4853db25fb9af42ffd82736440c16a804028879e73e2cd3b5eeac58bb2134c0e8dae


์ œ๋ณด๊ฐ€ ๋“ค์–ด์™€์„œ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.


์œ„์™€๊ฐ™์ด ๊ธ€๋กœ๋ฒŒ ๊ฒŒ์ž„ ์„ธํŒ…์˜ short-circuit evaluations ๋ฅผ ์ฒดํฌํ•ด์ฃผ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์ผ์€ ๋ฒŒ์–ด์ง€์ง€ ์•Š๋Š”๋‹ค๊ณ  ํ•˜๋„ค์š”



์ €๋Š” ๋‹ค์‹œ ์ •์‹ ์ค„์„ ๋ถ™์žก์„ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.








----------------------------------------------

์ด์ „ ๊ธ€๋‚ด์šฉ




์ถœ์ฒ˜ : http://www.yoyogames.com/blog/23



Nest "if"

Currently GameMaker:Studio does not do any "easy out" evaluation of if. Consider the following code:

ย 

if mouse_check_button(mb_left) && mouse_x > 200 && global.canshoot == true { //do something }

ย 

In many languages, the moment any one of the checks returns false, the rest are skipped and the next function is stepped into. However GameMaker:Studio will evaluate ALL of them, even if the first one is false. Therefore it is recommended that you "nest" your ifs like this:

ย 

if mouse_check_button(mb_left) { if mouse_x > 200 { if global.canshoot == true { //do something } } }

ย 

While this may seem verbose, in a logic heavy game where multiple checks like this are necessary, it can help keep things optimized.





๊ฒŒ์ž„๋ฉ”์ด์ปค ๋„ค์ด๋ฒ„ย ์นดํŽ˜ ๋‘˜๋Ÿฌ๋ณด๋‹ค๋ณด๋‹ˆ and๋ฅผ ์“ฐ๋ฉด ์•ˆ์ข‹๋‹ค๊ธธ๋ž˜ ํ•ด์„œ ์ฐพ์•„๋ดค๋”๋‹ˆ.....


(A<B) && (C<D) ์™€ ๊ฐ™์€ ์กฐ๊ฑด๋ฌธ์—์„œ A<B๊ฐ€ false ์ธ ๊ฒฝ์šฐ์—๋„ C<D๋ฅผ ๊ฒ€์‚ฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— if๋ฌธ์„ ๋‚˜๋ˆ ์“ฐ๋Š”๊ฒŒ ์ข‹๋‹ค๊ณ  ํ•˜๋„ค์š”.


์ €๋Š” ๊ทธ๋งŒ ์ •์‹ ์„ ์žƒ๊ณ  ๋ง์•˜์Šต๋‹ˆ๋‹ค.


--------------------------------------------------------------------