Cursor
Last updated
Was this helpful?
Was this helpful?
// Update
var cursor = GumService.Default.Cursor;
var isOverUi = cursor.WindowOver != null;
if(isOverUi == false)
{
PerformGameCursorLogic();
}protected override void Update(GameTime)
{
GumUI.Update(gameTime);
var cursor = GumUI.Cursor;
System.Diagnostics.Debug.WriteLine(cursor.WindowOver);
base.Update(gameTime);
}// Update
var cursor = GumService.Default.Cursor;
// A PrimaryClick means the cursor was released...
// and the WindowOver can be checked if it is over the area
// where the user must drop purchased items.
if(cursor.PrimaryClick && cursor.WindowOver == BuyArea)
{
// Get the item that was pushed
var itemDragged = cursor.WindowPushed;
// Make sure the user actually pushed on an item
if(itemDragged is ItemDisplay itemDisplay)
{
// This assumes the ItemDisplay is bound to an ItemViewModel
var itemToBuy = itemDisplay.BindingContext as ItemViewModel;
// use itemToBuy to do your game's logic when buying an item
}
}