GameChatOverlay Clase

Definición

Representa la superposición del chat del juego.

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
Herencia
Object Platform::Object IInspectable GameChatOverlay
Atributos

Requisitos de Windows

Familia de dispositivos
Windows 10 Creators Update (se introdujo en la versión 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (se introdujo en la versión v4.0)

Ejemplos

En este ejemplo se muestra cómo configurar el chat de juego y agregarle mensajes de texto.

#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.
    } 
}

Comentarios

Esta clase proporciona métodos para obtener la instancia de superposición de chat de juego predeterminada, establecer la posición deseada de la superposición y agregarle mensajes.

Propiedades

DesiredPosition

Posición deseada de la superposición del chat del juego.

Métodos

AddMessage(String, String, GameChatMessageOrigin)

Representar un mensaje en la superposición del chat del juego.

GetDefault()

Obtiene la instancia de superposición de chat de juego predeterminada.

Se aplica a

Consulte también