ZH-CN/fadeCamera: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
Qwe7769611 (talk | contribs) No edit summary  | 
				Qwe7769611 (talk | contribs)  No edit summary  | 
				||
| Line 26: | Line 26: | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
{{OOP||Camera.fade}}  | {{OOP||Camera.fade}}  | ||
===  | ===必填参数===  | ||
* '''fadeIn:''' Should the camera be faded in our out? Pass ''true'' to fade the camera in, ''false'' to fade it out to a color.  | * '''fadeIn:''' Should the camera be faded in our out? Pass ''true'' to fade the camera in, ''false'' to fade it out to a color.  | ||
===  | ===选填参数===  | ||
* '''timeToFade:'''   | * '''timeToFade:''' 淡出所需的秒数.  | ||
* '''red:'''   | * '''red:''' 相机淡出的颜色中红色的量(0-255).淡入不需要.  | ||
* '''green:'''   | * '''green:''' 相机淡出的颜色中绿色的量(0-255).淡入不需要.  | ||
* '''blue:'''   | * '''blue:''' 相机淡出的颜色中蓝色的量(0-255).淡入不需要.  | ||
</section>  | </section>  | ||
===Returns===  | ===Returns(返回)===  | ||
如果相机已成功淡出,则返回“true”;如果向函数传递了无效参数,则返回“false”.  | |||
==  | ==例子==  | ||
<section name="Server example" class="server" show="true">  | <section name="Server example" class="server" show="true">  | ||
When a player gets damaged, place a quick fade-to-red effect on his screen.  | When a player gets damaged, place a quick fade-to-red effect on his screen.  | ||
Revision as of 03:35, 3 February 2021
此功能将使玩家的相机在指定的时间段内淡入某一颜色或恢复正常。这也会影响播放器的音量(50%淡入=50%音量,完全淡入=无声音)。对于客户端脚本,您可以一行执行两个淡入淡出,但是对于服务器端脚本,您必须先使用一个,然后使用另一个.
语法
Click to collapse [-]
服务端bool fadeCamera ( player thePlayer, bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )
OOP Syntax Help! I don't understand this!
- Method: player:fadeCamera(...)
 
必填参数
- thePlayer: 你想淡出相机的玩家.
 - fadeIn: 相机应该淡入还是淡出?通过true使相机淡入,通过false使其淡出颜色.
 
选填参数
- timeToFade: 淡出所需的秒数.
 - red: 相机淡出的颜色中红色的量(0-255).淡入不需要.
 - green: 相机淡出的颜色中绿色的量(0-255).淡入不需要.
 - blue: 相机淡出的颜色中蓝色的量(0-255).淡入不需要.
 
Click to collapse [-]
客户端bool fadeCamera ( bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )
OOP Syntax Help! I don't understand this!
- Method: Camera.fade(...)
 
必填参数
- fadeIn: Should the camera be faded in our out? Pass true to fade the camera in, false to fade it out to a color.
 
选填参数
- timeToFade: 淡出所需的秒数.
 - red: 相机淡出的颜色中红色的量(0-255).淡入不需要.
 - green: 相机淡出的颜色中绿色的量(0-255).淡入不需要.
 - blue: 相机淡出的颜色中蓝色的量(0-255).淡入不需要.
 
Returns(返回)
如果相机已成功淡出,则返回“true”;如果向函数传递了无效参数,则返回“false”.
例子
Click to collapse [-]
Server exampleWhen a player gets damaged, place a quick fade-to-red effect on his screen.
function addRednessOnDamage ( )
      fadeCamera ( source, false, 1.0, 255, 0, 0 )         -- fade the player's camera to red over a period of 1 second
      setTimer ( fadeCameraDelayed, 500, 1, source )   -- don't let it go to opaque red, interrupt it after half a second and fade back to normal
end
addEventHandler ( "onPlayerDamage", root, addRednessOnDamage )
function fadeCameraDelayed(player) -- This function prevents debug warnings when the player disconnects while the timer is running.
      if (isElement(player)) then
            fadeCamera(player, true, 0.5)
      end
end