PlayerMouse

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建

玩家鼠标与使用 获得的对象相同行为。它可以使用本地玩家的 LocalScripts 方法从 Player:GetMouse() 访问。PlayerMouse 和 Mouse 都是遗产 API,被 UserInputService 取代。

玩家鼠标和 Mouse 对象之间的唯一差异是玩家鼠标可以使用 Player:GetMouse() 方法获得。

在大多数情况下,开发人员建议使用新的 UserInputService 。但是,玩家鼠标和鼠标对象仍然支持多种原因。请参阅输入和相机获取有关体验中自定义输入的更多信息。

代码示例

This code sample includes a simple example of how the local player's PlayerMouse can be retrieved using the Player:GetMouse() function in a LocalScript. This code should be placed in a LocalScript in StarterPlayerScripts.

PlayerMouse

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local function onMouseMove()
print("mouse screen position: ", mouse.X, mouse.Y)
end
mouse.Move:Connect(onMouseMove)

概要

属性

继承自Mouse属性

属性

活动

继承自Mouse活动

活动

属性

方法

活动