本文整理汇总了C#中SFML.Graphics.RenderWindow.SetMouseCursorVisible方法的典型用法代码示例。如果您正苦于以下问题:C# RenderWindow.SetMouseCursorVisible方法的具体用法?C# RenderWindow.SetMouseCursorVisible怎么用?C# RenderWindow.SetMouseCursorVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.RenderWindow
的用法示例。
在下文中一共展示了RenderWindow.SetMouseCursorVisible方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWindow
private RenderWindow CreateWindow(ApplicationSettings settings)
{
var windowStyle = settings.Fullscreen ? Styles.Fullscreen : Styles.Close;
var window = new RenderWindow(settings.VideoMode, settings.WindowCaption, windowStyle);
window.SetMouseCursorVisible(settings.MouseCursorVisible);
window.SetVerticalSyncEnabled(settings.VerticalSyncEnabled);
if (settings.FramerateLimit > 0)
window.SetFramerateLimit(settings.FramerateLimit);
return window;
}
示例2: InitializeWindow
private static void InitializeWindow()
{
//Construct
window = new RenderWindow(new VideoMode(1920, 1080), "Orbs", IsFullscreen ? Styles.Fullscreen : Styles.Default);
//Set parameters
window.SetVisible(true);
window.SetMouseCursorVisible(false);
window.SetVerticalSyncEnabled(IsVSyncEnabled);
//Bind events
window.Closed += (sender, i) => window.Close();
window.KeyPressed += (sender, i) => stateManager.CurrentState?.HandleKeyPressed(i);
window.KeyPressed += (sender, i) => { if (i.Code == Keyboard.Key.F11) { window.Close(); IsFullscreen = !IsFullscreen; InitializeWindow(); } };
}
示例3: OnRenderWindowChanged
/// <summary>
/// Handles the <see cref="IGameContainer.RenderWindowChanged"/> event.
/// </summary>
/// <param name="oldValue">The old value.</param>
/// <param name="newValue">The new value.</param>
protected virtual void OnRenderWindowChanged(RenderWindow oldValue, RenderWindow newValue)
{
if (newValue == null)
return;
newValue.SetMouseCursorVisible(ShowMouseCursor);
newValue.SetVerticalSyncEnabled(UseVerticalSync);
newValue.SetActive();
newValue.SetVisible(true);
}
示例4: Init
private void Init()
{
Music = new MusicPlayer();
Sounds = new SoundManager();
Assets = new Assets();
Assets.Load();
var vm = new SFML.Window.VideoMode(1000, 750, 32);
var style = Styles.Close;
var settings = new ContextSettings(0, 0, 8);
Window = new SFML.Graphics.RenderWindow(vm, "", style, settings);
Window.SetView(View);
Window.SetVerticalSyncEnabled(true);
Window.Closed += (sender, e) => { IsAppExited = true; };
Window.LostFocus += (sender, e) => { IsPaused = true; };
Window.GainedFocus += (sender, e) => { IsPaused = false; };
Window.SetMouseCursorVisible(true);
var splash = new Space("Splash", true);
var menu = new Space("Menu");
var inGame = new Space("InGame");
var gameOver = new Space("GameOver");
// ----- ----- ----- Splash ----- ----- -----
var images = new SplashImage[]
{
new SplashImage(Assets.Textures["sfml"], 3, 1, 1),
new SplashImage(Assets.Textures["rsas"], 5, 1, 1)
};
SplashImage.Prepare(images, e =>
{
splash.IsActive = false;
menu.IsActive = true;
});
foreach(var image in images)
splash.Add(image);
// ----- ----- ----- Menu ----- ----- -----
var btnStart = new MenuButton("Play", 40, new Vector(100, 100));
var btnQuit = new MenuButton("Quit", 40, new Vector(100, 200));
var btnDiffEasy = new MenuButton("Easy", 30, new Vector(250, 100));
var btnDiffMedium = new MenuButton("Medium", 30, new Vector(250, 150));
var btnDiffHard = new MenuButton("Hard", 30, new Vector(250, 200));
var infoText =
"- Instructions -\n" +
"- Run, shoot and survive as long as possible.\n" +
"- Collect white powersups to recover health.\n" +
"- New weapons are unlocked after each 1000 kills.\n" +
"\n" +
"- Use WASD keys to move, and mouse to aim and shoot.\n" +
"- Use the numbers keys to change weapons.\n" +
"- During gameplay, press ESC to pause or F1 to give up.";
var btnInfoText = new MenuButton(infoText, 20, new Vector(450, 125));
var highscoreList = new HighscoreList(new Vector2f(50, 300));
Difficulty = RSaS.Difficulty.Medium;
btnDiffMedium.Text.Color = Color.Red;
btnStart.Click += e =>
{
if (IsGameOver)
{
IsGameOver = false;
InitInGame(inGame);
}
Music.Play("music");
menu.IsActive = false;
inGame.IsActive = true;
IsOSCursorVisible = false;
};
btnQuit.Click += e =>
{
IsAppExited = true;
};
btnDiffEasy.Click += e =>
{
if (!IsGameOver)
return;
Difficulty = RSaS.Difficulty.Easy;
btnDiffEasy.Text.Color = Color.Red;
btnDiffMedium.Text.Color = Color.White;
btnDiffHard.Text.Color = Color.White;
};
btnDiffMedium.Click += e =>
{
if (!IsGameOver)
return;
//.........这里部分代码省略.........
示例5: Main
static void Main(string[] args)
{
Texture textureBack = new Texture(File.ReadAllBytes(@"assets/back.png"));
textureBack.Smooth = true;
Sprite spriteBack = new Sprite(textureBack, new IntRect(0, 0, 800, 500));
Texture textureLock = new Texture(File.ReadAllBytes(@"assets/lock.png"));
textureLock.Smooth = true;
Sprite spriteLock = new Sprite(textureLock, new IntRect(0, 0, 80, 80));
spriteLock.Position = new Vector2f(76, 68);
icons = new List<Sprite>();
for (int index = 0; index < 15; index++)
{
int col = index % 5;
int row = (index - col) / 5;
Texture textureIcon = new Texture(File.ReadAllBytes(String.Format(@"assets/buttons/{0:00}.png", index + 1)));
textureIcon.Smooth = true;
Sprite spriteIcon = new Sprite(textureIcon, new IntRect(0, 0, 72, 72));
spriteIcon.Position = new Vector2f(80 + col * 72 + col * 70, 72 + row * 72 + row * 70);
icons.Add(spriteIcon);
}
ContextSettings context = new ContextSettings();
context.DepthBits = 32;
RenderWindow window = new RenderWindow(new VideoMode(800, 500), String.Empty, Styles.Default, context);
window.SetActive();
window.SetVisible(true);
window.SetKeyRepeatEnabled(true);
window.SetMouseCursorVisible(true);
window.SetVerticalSyncEnabled(false);
window.Closed += new EventHandler(
delegate(object sender, EventArgs e)
{
window.Close();
window.Dispose();
}
);
window.GainedFocus += new EventHandler(
delegate(object sender, EventArgs e)
{
}
);
window.LostFocus += new EventHandler(
delegate(object sender, EventArgs e)
{
}
);
window.KeyPressed += new EventHandler<KeyEventArgs>(
delegate(object sender, KeyEventArgs e)
{
if (e.Code == Keyboard.Key.Escape)
{
/*
sound.Stop();
sound.Dispose();
buffer.Dispose();
*/
window.Close();
window.Dispose();
}
if (e.Code == Keyboard.Key.Right)
{
if (col < 4)
{
col += 1;
}
}
//.........这里部分代码省略.........
示例6: LoadContentInitialize
private static void LoadContentInitialize()
{
Char1Model = new Model();
Char1Model.name = "Character_1_Model";
Char1Model.gibArmFile = "gibArm.png";
Char1Model.gibBodyFile = "gibBody.png";
Char1Model.gibHeadFile = "gibHead.png";
Char1Model.gibLowerLegFile = "gibLowerLeg.png";
Char1Model.gibUpperLegFile = "gibUpperLeg.png";
Char1Model.idleFile = "idle.png";
Char1Model.jumpDownFile = "jumpDown.png";
Char1Model.jumpUpFile = "jumpUp.png";
Char1Model.runFile = "run.png";
Char1Model.pistolHand = "pistolHand.png";
Char2Model = new Model();
Char2Model.name = "Character_2_Model";
Char2Model.gibArmFile = "char2_gibArm.png";
Char2Model.gibBodyFile = "char2_gibBody.png";
Char2Model.gibHeadFile = "char2_gibHead.png";
Char2Model.gibLowerLegFile = "char2_gibLowerLeg.png";
Char2Model.gibUpperLegFile = "char2_gibUpperLeg.png";
Char2Model.idleFile = "char2_idle.png";
Char2Model.jumpDownFile = "char2_jumpDown.png";
Char2Model.jumpUpFile = "char2_jumpUp.png";
Char2Model.runFile = "char2_run.png";
Char2Model.pistolHand = "char2_pistolHand.png";
window = new RenderWindow(
new VideoMode(800, 600), "Project Iris", Styles.Resize);
window.SetFramerateLimit(60);
window.SetMouseCursorVisible(false);
window.Closed += (o, e) =>
{
dm.Close();
window.Close();
};
window.GainedFocus += (o, e) =>
{
Input.isActive = true;
};
window.LostFocus += (o, e) =>
{
Input.isActive = false;
};
Camera = new View(window.DefaultView);
Camera.Size = new Vector2f(800 / 2, 600 / 2);
GuiCamera = new View(window.DefaultView);
GuiCamera.Size = new Vector2f(800 / 2, 600 / 2);
soundInstances = new List<SoundInstance>() { };
dm = new Deathmatch();
mm = new Menu();
gamestate = mm;
}
示例7: Main
static void Main()
{
// Create the main window
CurrentSaveData = 0;
Data d = new Data();
Data = d;
d.CreateTerrain();
d.CreateSpriteData();
d.CreateTileData();
d.CreateItems();
d.CreateSpawnable();
List<GameState> _gameState = new List<GameState>();
State = _gameState;
MainMap m;
MouseState = 0;
InState = 0;
MapGenerator mg = new MapGenerator();
m = mg.NewMap();
MyMap = m;
Generator = mg;
d.CreateLivingObjectData();
PlayerData test = new PlayerData();
test.MainParty.AddMember(((NPC)d.MyLivingObject[0]));
d.MyPlayerData.Add(test);
d.MyPlayerData[CurrentSaveData].MainParty.MyParty[0].Inventory[0] = new SpawnItems(0);
d.MyPlayerData[CurrentSaveData].MainParty.MyParty[0].Inventory[1] = new SpawnItems(1);
d.MyPlayerData[CurrentSaveData].MainParty.MyParty[0].Inventory[2] = new SpawnItems(1);
//d.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].EquipItems(1);
d.MyPlayerData[CurrentSaveData].MainParty.AddMember((NPC)d.MyLivingObject[1]);
Font font = new Font("Georgia.ttf");
List<string> stuff = new List<string>();
RenderWindow Screen = new RenderWindow(new VideoMode(1040, 768), "Wandering Soul - The Legacy");
RW = Screen;
Screen.SetFramerateLimit(60);
Screen.Closed += new EventHandler(OnClose);
Screen.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
Screen.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(OnMousePress);
Screen.MouseMoved += new EventHandler<MouseMoveEventArgs>(OnMouseMove);
Screen.MouseButtonReleased += new EventHandler<MouseButtonEventArgs>(OnMouseRelease);
Screen.SetMouseCursorVisible(false);
_gameState.Add(new MainMenuState(Screen));
_gameState.Add(new InGameState(Screen, 0));
Color windowColor = new Color(0, 0, 0);
Text t;
SFML.Graphics.Sprite s;
// Start the game loop
while (Screen.IsOpen()) {
// Process events
stuff.Clear();
string ministuff = "";
foreach (Terrain ter in MyMap.SpawnedTerrain)
{
ministuff = "";
ministuff += ter.MinHorizontal + ", " + ter.MaxHorizontal + ", " + ter.MinVertical + ", " + ter.MaxVertical;
stuff.Add(ministuff);
}
Screen.DispatchEvents();
// Clear screen
Screen.Clear(windowColor);
_gameState[InState].Update();
_gameState[InState].Draw();
/*for (int i = 0; i < stuff.Count; i++)
{
t = new Text(stuff[i], font);
t.Position = new Vector2f(50, i * 20 + 50);
Screen.Draw(t);
}*/
//t = new Text("Min X: " + MyMap.MinX + ", Min Y: " + MyMap.MinY + ", Max X: " + MyMap.MaxX + ", Max Y: " + MyMap.MaxY + ", " + MyMap.SpawnedTerrain[0].Size.ToString() + ", Spawned Terrain Count: " + MyMap.SpawnedTerrain.Count, font);
//t.Position = new Vector2f(0, 0);
//Screen.Draw(t);
t = new Text("X: " + (Mouse.GetPosition(Screen).X / 16 + Program.Data.MyPlayerData[CurrentSaveData].MainParty.MyParty[0].X - Screen.Size.X / 2 / 16 - 1) + ", Y: " + ((Mouse.GetPosition(Screen).Y + 8) / 16 + Program.Data.MyPlayerData[CurrentSaveData].MainParty.MyParty[0].Y - Screen.Size.Y / 2 / 16 - 1), Program.Data.Font);
Screen.SetView(new View(new FloatRect(0, 0, Screen.Size.X, Screen.Size.Y)));
t.Position = new Vector2f(0, 0);
Screen.Draw(t);
s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Mouse)[MouseState]);
switch ((MouseStateType)MouseState)
{
case MouseStateType.Normal:
s.Position = new Vector2f(Mouse.GetPosition(Screen).X - 3, Mouse.GetPosition(Screen).Y);
break;
//.........这里部分代码省略.........
开发者ID:ComposerCookie,项目名称:WanderingSoul,代码行数:101,代码来源:Program+(Jacqueline+Tran's+conflicted+copy+2014-10-27).cs
示例8: InitWindow
public static bool InitWindow(Styles style)
{
int width, height;
if (!_game.TryGetData("screen_width", out width))
{
Console.WriteLine("No screen width set in game.sgm.");
return false;
}
if (!_game.TryGetData("screen_height", out height))
{
Console.WriteLine("No screen height set in game.sgm.");
return false;
}
if (width <= 0 || height <= 0)
{
Console.WriteLine("Invalid width and height in game.sgm.");
return false;
}
GlobalProps.Width = width;
GlobalProps.Height = height;
if (Scaled)
{
width *= 2;
height *= 2;
}
_clipper.Width = width;
_clipper.Height = height;
GlobalProps.BasePath = Path.GetDirectoryName(_game.FileName);
if (!_game.TryGetData("name", out GlobalProps.GameName))
{
Console.WriteLine("No name set in game.sgm.");
return false;
}
if (style == Styles.Fullscreen && (width < 640 || height < 480))
{
width = 640;
height = 480;
}
_window = new RenderWindow(new VideoMode((uint)width, (uint)height), GlobalProps.GameName, style);
if (Scaled)
{
View v = _window.GetView();
v.Size = new Vector2f(GlobalProps.Width, GlobalProps.Height);
v.Center = new Vector2f(GlobalProps.Width / 2, GlobalProps.Height / 2);
_window.SetView(v);
}
_window.SetMouseCursorVisible(false);
GlobalInput.AddWindowHandlers(_window);
Program._window.SetFramerateLimit((uint)_internal_fps);
Program._window.SetMouseCursorVisible(false);
GlobalPrimitives.Target = _window;
Batch = new SpriteBatch(_window);
FindIcon();
return true;
}
示例9: Main
static void Main()
{
// Create the main window
CurrentSaveData = 0;
Data d = new Data();
Data = d;
d.CreateGraphicPath();
d.CreateTerrain();
d.CreateSpriteData();
d.CreateTileData();
d.CreateAnimation();
d.CreateAttack();
d.CreateItems();
d.CreateSpawnable();
d.CreateKnowledge();
d.CreateFaceData();
d.CreateBodyData();
d.CreateHairData();
d.CreateTileVariation();
d.LoadPlayerData();
d.LoadWorldData();
List<GameState> _gameState = new List<GameState>();
State = _gameState;
MainMap m;
MouseState = 0;
InState = 0;
MapGenerator mg = new MapGenerator();
m = mg.NewMap();
MyMap = m;
Generator = mg;
Font font = new Font("Georgia.ttf");
List<string> stuff = new List<string>();
RenderWindow Screen = new RenderWindow(new VideoMode(1040, 768), "Wandering Soul - The Legacy");
VisibleMaxX = 1040 / 16;
VisibleMaxY = 768 / 16;
RW = Screen;
Screen.SetFramerateLimit(60);
Screen.Closed += new EventHandler(OnClose);
Screen.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
Screen.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(OnMousePress);
Screen.MouseMoved += new EventHandler<MouseMoveEventArgs>(OnMouseMove);
Screen.MouseButtonReleased += new EventHandler<MouseButtonEventArgs>(OnMouseRelease);
Screen.Resized +=new EventHandler<SizeEventArgs>(OnScreenResize);
Screen.SetMouseCursorVisible(false);
_gameState.Add(new MainMenuState(Screen));
_gameState.Add(new InGameState(Screen));
Color windowColor = new Color(0, 0, 0);
Text t;
SFML.Graphics.Sprite s;
// Start the game loop
while (Screen.IsOpen()) {
// Process events
Screen.DispatchEvents();
// Clear screen
Screen.Clear(windowColor);
_gameState[InState].Update();
_gameState[InState].Draw();
/*for (int i = 0; i < stuff.Count; i++)
{
t = new Text(stuff[i], font);
t.Position = new Vector2f(50, i * 20 + 50);
Screen.Draw(t);
}*/
//t = new Text("Min X: " + MyMap.MinX + ", Min Y: " + MyMap.MinY + ", Max X: " + MyMap.MaxX + ", Max Y: " + MyMap.MaxY + ", " + MyMap.SpawnedTerrain[0].Size.ToString() + ", Spawned Terrain Count: " + MyMap.SpawnedTerrain.Count, font);
//t.Position = new Vector2f(0, 0);
//Screen.Draw(t);
Screen.SetView(new View(new FloatRect(0, 0, Screen.Size.X, Screen.Size.Y)));
s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Mouse)[MouseState]);
switch ((MouseStateType)MouseState)
{
case MouseStateType.Normal:
s.Position = new Vector2f(Mouse.GetPosition(Screen).X - 3, Mouse.GetPosition(Screen).Y);
break;
case MouseStateType.Dragging:
s.Position = new Vector2f(Mouse.GetPosition(Screen).X - 2, Mouse.GetPosition(Screen).Y + 3);
break;
}
Screen.Draw(s);
// Update the window
Screen.Display();
} //End game loop
}