GameChatOverlay Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Представляет наложение игрового чата.
public ref class GameChatOverlay sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class GameChatOverlay final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class GameChatOverlay
Public NotInheritable Class GameChatOverlay
- Наследование
- Атрибуты
Требования к Windows
Семейство устройств |
Windows 10 Creators Update (появилось в 10.0.15063.0)
|
API contract |
Windows.Foundation.UniversalApiContract (появилось в v4.0)
|
Примеры
В этом примере демонстрируется настройка игрового чата и добавление в него текстовых сообщений.
#include <winrt/Windows.Gaming.UI.h>
using namespace winrt;
using namespace Windows::Gaming::UI;
...
GameChatOverlay m_gameChatOverlay{nullptr};
...
void ChatSample::SetUpGameChat(GameChatOverlayPosition position)
{
// Get the default game chat overlay object. Platforms that don't support
// it will return null.
m_gameChatOverlay = GameChatOverlay::GetDefault();
if (m_gameChatOverlay)
{
// Position the overlay in the given position.
m_gameChatOverlay.DesiredPosition(position);
}
}
// This method typically would be wired to a text entry box in order to send
// text messages.
void ChatSample::SendTextMessage(std::wstring gamertag, std::wstring message)
{
if (m_gameChatOverlay)
{
// Render the text in the overlay.
m_gameChatOverlay.AddMessage(
gamertag,
message,
GameChatMessageOrigin::Text);
}
else
{
// The game should render the outgoing message in its own UI.
}
}
void ChatSample::SetUpGameChat(GameChatOverlayPosition position)
{
// Get the default game chat overlay object. Platforms that don't support
// it will return null.
m_gameChatOverlay = GameChatOverlay::GetDefault();
if (m_gameChatOverlay)
{
// Position the overlay in the given position.
m_gameChatOverlay->DesiredPosition = position;
}
}
// This method typically would be wired to a text entry box in order to send
// text messages.
void ChatSample::SendTextMessage(String^ gamertag, String^ message)
{
if (m_gameChatOverlay)
{
// Render the text in the overlay.
m_gameChatOverlay->AddMessage(
gamertag,
message,
GameChatMessageOrigin::Text);
}
else
{
// The game should render the outgoing message in its own UI.
}
}
Комментарии
Этот класс предоставляет методы для получения экземпляра наложения игрового чата по умолчанию, задания нужной позиции наложения и добавления в него сообщений.
Свойства
DesiredPosition |
Требуемое положение наложения игрового чата. |
Методы
AddMessage(String, String, GameChatMessageOrigin) |
Отрисовка сообщения в наложении игрового чата. |
GetDefault() |
Возвращает экземпляр наложения игрового чата по умолчанию. |