FlightStick.FlightStickAdded 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
连接新飞行杆时发出信号。
// Register
static event_token FlightStickAdded(EventHandler<FlightStick> const& handler) const;
// Revoke with event_token
static void FlightStickAdded(event_token const* cookie) const;
// Revoke with event_revoker
static FlightStick::FlightStickAdded_revoker FlightStickAdded(auto_revoke_t, EventHandler<FlightStick> const& handler) const;
public static event System.EventHandler<FlightStick> FlightStickAdded;
function onFlightStickAdded(eventArgs) { /* Your code */ }
Windows.Gaming.Input.FlightStick.addEventListener("flightstickadded", onFlightStickAdded);
Windows.Gaming.Input.FlightStick.removeEventListener("flightstickadded", onFlightStickAdded);
- or -
Windows.Gaming.Input.FlightStick.onflightstickadded = onFlightStickAdded;
Public Shared Custom Event FlightStickAdded As EventHandler(Of FlightStick)
事件类型
示例
以下示例开始跟踪已添加的飞行摇杆。
#include <winrt/Windows.Gaming.Input.h>
using namespace winrt;
using namespace Windows::Gaming::Input;
...
std::vector<FlightStick> m_myFlightSticks;
...
FlightStick::FlightStickAdded([this](IInspectable const& /* sender */, FlightStick const& args)
{
m_myFlightSticks.push_back(args);
});
FlightStick::FlightStickAdded +=
ref new EventHandler<FlightStick^>([] (Platform::Object^, FlightStick^ args)
{
// This code assumes that you're interested in all new flight sticks.
// `myFlightSticks` is a `Vector<FlightStick^>` that contains the flight sticks that your game is tracking.
myFlightSticks->Append(args);
});
注解
若要识别已添加的飞行杆,请使用 FlightStick.FlightSticks 查询连接的飞行杆列表。 但是,由于你可能只对某些连接的飞行杆感兴趣,因此我们建议你维护自己的集合,而不是通过 FlightSticks 访问它们。