Rasterizer
Wikipedia,自由的百科全书
光栅模块
Documentation for the Rasterizer module.
Example Uses an SCA_MouseSensor, and two KX_ObjectActuators to implement MouseLook:
这个例子使用一个鼠标传感器和两个物体执行器实现鼠标视野:
# To use a mouse movement sensor "Mouse" and a motion actuator to mouse look:
/*使用一个鼠标动作传感器和一个运动执行器实现鼠标视野*/
import Rasterizer
import GameLogic
# SCALE sets the speed of motion 设置运动速度
SCALE=[1, 0.5]
co = GameLogic.getCurrentController()
obj = co.getOwner()
mouse = co.getSensor("Mouse")
lmotion = co.getActuator("LMove")
wmotion = co.getActuator("WMove")
# Transform the mouse coordinates to see how far the mouse has moved.
/*转换鼠标移动相匹配的视觉距离*/
def mousePos():
x = (Rasterizer.getWindowWidth()/2 - mouse.getXPosition())*SCALE[0]
y = (Rasterizer.getWindowHeight()/2 - mouse.getYPosition())*SCALE[1]
return (x, y)
pos = mousePos()
# Set the amount of motion: X is applied in world coordinates...
/*设置移动量:X应用与世界相匹配*/
lmotion.setTorque(0.0, 0.0, pos[0], False)
# ...Y is applied in local coordinates
/*Y应用与当前相匹配*/
wmotion.setTorque(-pos[1], 0.0, 0.0, True)
# Activate both actuators
/*激活这两个执行器*/
GameLogic.addActiveActuator(lmotion, True)
GameLogic.addActiveActuator(wmotion, True)
# Centre the mouse
/*初始鼠标坐标在屏幕中央*/
Rasterizer.setMousePosition(Rasterizer.getWindowWidth()/2, Rasterizer.getWindowHeight()/2)
________________________________________ Function Summary 函数概要
enableVisibility(visible) 打开能见度
Doesn't really do anything... 不真正的执行 integer 整形 getWindowHeight() 得到窗口的高 Gets the height of the window (in pixels) integer 整形 getWindowWidth() 得到窗口的宽 Gets the width of the window (in pixels)
makeScreenshot(filename) 抓屏到文件
Writes a screenshot to the given filename.
setBackgroundColor(rgba) 设置背景颜色
Sets the window background colour.
setMistColor(rgb) 设置雾颜色
Sets the mist colour.
setMistEnd(end) 设置雾结束的值
Sets the mist end value.
setMistStart(start) 设置雾开始的值
Sets the mist start value.
setMousePosition(x, y) 设置鼠标坐标
Sets the mouse cursor position.
showMouse(visible) 打开或关闭操作系统的鼠标指针
Enables or disables the operating system mouse cursor.
Function Details 函数详细资料
enableVisibility(visible) Doesn't really do anything...
getWindowHeight() Gets the height of the window (in pixels) Returns: integer
getWindowWidth() Gets the width of the window (in pixels) Returns: integer
makeScreenshot(filename) Writes a screenshot to the given filename. Parameters: filename
(type=string)
setBackgroundColor(rgba) Sets the window background colour. Parameters: rgba
(type=list [r, g, b, a])
setMistColor(rgb) Sets the mist colour. Parameters: rgb
(type=list [r, g, b])
setMistEnd(end) Sets the mist end value. Objects further away from this will be coloured solid with the colour set by setMistColor(). Parameters: end
(type=float)
setMistStart(start) Sets the mist start value. Objects further away than start will have mist applied to them. Parameters: start
(type=float)
setMousePosition(x, y) Sets the mouse cursor position. Parameters: x
(type=integer)
y
(type=integer)
showMouse(visible) Enables or disables the operating system mouse cursor. Parameters: visible
(type=boolean)
