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存取它們。