我是在 actionscript3 中编码的新手。我的问题是连字符在这段代码中的作用是什么?
tween = new Tween(menuScreen,"y",Strong.easeOut,menuScreen.y, - /* <---- */
menuScreen.height / 2,0.8,true);//Creates a tween animating the MenuView up
我是在 actionscript3 中编码的新手。我的问题是连字符在这段代码中的作用是什么?
tween = new Tween(menuScreen,"y",Strong.easeOut,menuScreen.y, - /* <---- */
menuScreen.height / 2,0.8,true);//Creates a tween animating the MenuView up
它这样做:
menuScreen.y, -menuScreen.height/2,0.8,true
基本上menuScreen.height
是负数。如果menuScreen.height = 200
那么方程将是-200/2 = -100
它是一元运算-
符。
当用于取反时,运算符反转数字表达式的符号。
也就是说,提供的代码等价于更常见的形式:
tween = new Tween(menuScreen,"y",Strong.easeOut,menuScreen.y,
-menuScreen.height / 2,0.8,true)
换行符的放置是不幸的(为了可读性),但不影响解析。