本文整理汇总了C#中SFML.Graphics.RenderWindow.SetView方法的典型用法代码示例。如果您正苦于以下问题:C# RenderWindow.SetView方法的具体用法?C# RenderWindow.SetView怎么用?C# RenderWindow.SetView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.RenderWindow
的用法示例。
在下文中一共展示了RenderWindow.SetView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// initialize window and view
win = new RenderWindow(new VideoMode(1000, 700), "Hadoken!!!");
view = new View();
resetView();
gui = new GUI(win, view);
// exit Program, when window is being closed
//win.Closed += new EventHandler(closeWindow);
win.Closed += (sender, e) => { (sender as Window).Close(); };
// initialize GameState
handleNewGameState();
// initialize GameTime
GameTime gameTime = new GameTime();
gameTime.Start();
// debug Text
Text debugText = new Text("debug Text", new Font("Fonts/calibri.ttf"));
while (running && win.IsOpen())
{
KeyboardInputManager.update();
currentGameState = state.update();
// gather draw-stuff
win.Clear(new Color(100, 149, 237)); //cornflowerblue ftw!!! 1337
state.draw(win, view);
state.drawGUI(gui);
// first the state must be drawn, before I can change the currentState
if (currentGameState != prevGameState)
{
handleNewGameState();
}
// do the actual drawing
win.SetView(view);
win.Display();
// check for window-events. e.g. window closed
win.DispatchEvents();
// update GameTime
gameTime.Update();
float deltaTime = (float)gameTime.EllapsedTime.TotalSeconds;
// idleLoop for fixed FrameRate
float deltaPlusIdleTime = deltaTime;
while (deltaPlusIdleTime < (1F / fixedFps))
{
gameTime.Update();
deltaPlusIdleTime += (float)gameTime.EllapsedTime.TotalSeconds;
}
Console.WriteLine("real fps: " + (int)(1F / deltaPlusIdleTime) + ", theo fps: " + (int)(1F / deltaTime));
}
}
示例2: ViewAnimateSprite
public ViewAnimateSprite(IntPtr handle)
{
_animatedSpriteViewer = new RenderWindow(handle);
_view = new View(new FloatRect(0, 0, Editor.Instance.curGame.TileX, Editor.Instance.curGame.TileY));
_curFrame = 0;
_animatedSpriteViewer.SetView(_view);
}
示例3: OnResized
public static void OnResized(object sender, SizeEventArgs e)
{
LocalWindow = (RenderWindow) sender;
LocalWindow.Size = new Vector2u(e.Width, e.Height);
// ReSharper disable PossibleLossOfFraction
LocalWindow.SetView(new View(new Vector2f((e.Width)/2, (e.Height)/2), new Vector2f(e.Width, e.Height)));
// ReSharper restore PossibleLossOfFraction
}
示例4: intialize
public override void intialize(RenderWindow window)
{
base.intialize(window);
window.SetView(new View(new FloatRect(0, 0, Game1.drawResolution.X, Game1.drawResolution.Y)));
window.SetFramerateLimit(60);
window.MouseButtonPressed += window_MouseButtonPressed;
window.KeyPressed += window_KeyPressed;
window.Resized += window_Resized;
}
示例5: Main
public static void Main(string[] args)
{
Window = new RenderWindow(new VideoMode(640, 480), "", Styles.Close);
Window.SetFramerateLimit(60);
Window.Closed += (sender, eventArgs) => Window.Close();
Window.Resized += (sender, eventArgs) =>
{
var view = new View();
view.Size = new Vector2f(eventArgs.Width, eventArgs.Height);
view.Center = view.Size / 2;
Window.SetView(view);
};
Machine = new VirtualMachine(512 * 1024);
var prog = File.ReadAllBytes("bios.bin");
for (var i = 0; i < prog.Length; i++)
Machine.Memory[i] = prog[i];
var kbd = new Devices.Keyboard(0x02, Window);
Machine.Attach(kbd);
var display = new Devices.Display(0x06, Machine, Window);
Machine.Attach(display);
var hdd = new Devices.HardDrive(0x08, "disk.img");
Machine.Attach(hdd);
var running = true;
var stepThread = new Thread(() =>
{
while (running)
{
Machine.Step();
}
});
stepThread.Start();
while (Window.IsOpen())
{
Window.DispatchEvents();
Window.Clear();
Window.Draw(display);
Window.Display();
}
running = false;
stepThread.Join();
Machine.Dispose();
}
示例6: Draw
/// <summary>
/// clear the window
/// <para>draws all gameobjects in the window</para>
/// <para>displays all drawn objects</para>
/// </summary>
static void Draw(RenderWindow window)
{
window.Clear(new Color(50, 120, 190));
window.SetView(Camera);
map.Draw(window);
Player.Draw(window);
enemy1.Draw(window);
enemy2.Draw(window);
window.Display();
}
示例7: Draw
public void Draw(RenderWindow win)
{
win.SetView(Camera);
map.Draw(win);
Player.Draw(win);
enemy1.Draw(win);
enemy2.Draw(win);
foreach (ParticleHandler p in pHandler)
p.Draw(win);
}
示例8: Draw
public override void Draw(RenderWindow window)
{
try {
window.SetView(Level.Camera);
Level.Draw(window);
}
catch (Exception e) {
Log.WriteError("Erreur lors du dessinage du niveau ! Le niveau est sûrement corrompu ou comporte des erreurs ! Erreur : " + e.Message);
Game.LoadScene(new MainMenuScene(Game));
}
}
示例9: Draw
static void Draw(RenderWindow window)
{
window.Clear(new SFML.Graphics.Color(50, 120, 190));
map.Draw(window);
mons01.Draw(window);
mons02.Draw(window);
// vulkan.Draw(window);
if(tool.isOnMap)tool.Draw(window);
Player.Draw(window);
window.Display();
window.SetView(view);
}
示例10: MapViewer
public MapViewer(IntPtr obj, int objw, int objh)
{
_xoffset = _yoffset = 0;
_mapWindow = new RenderWindow(obj);
_mapWindow.SetFramerateLimit(60);
_mapView = new View(new FloatRect(0, 0, objw, objh));
_mapWindow.SetView(_mapView);
_grid = true;
_block = true;
_showGround = true;
_showFringe = true;
_gEngine = new GEngine();
LoadedNewTS();
}
示例11: Game
public Game()
{
RWindow = new RenderWindow(new VideoMode(800, 600),"",Styles.Close);
//RWindow.SetFramerateLimit(60);
RWindow.MouseMoved += RWindow_MouseMoved;
RWindow.KeyPressed += RWindow_KeyPressed;
RWindow.KeyReleased += RWindow_KeyReleased;
RWindow.MouseButtonPressed += RWindow_MouseButtonPressed;
RWindow.MouseButtonReleased += RWindow_MouseButtonReleased;
RWindow.MouseLeft += RWindow_MouseLeft;
RWindow.MouseEntered += RWindow_MouseEntered;
RWindow.MouseWheelMoved += RWindow_MouseWheelMoved;
RWindow.TextEntered += RWindow_TextEntered;
RWindow.Closed += RWindow_Closed;
RWindow.LostFocus += RWindow_LostFocus;
RWindow.GainedFocus += RWindow_GainedFocus;
MainView = new View(RWindow.DefaultView);
RWindow.SetView(MainView);
//SM = new UI.ScreenManager(this);
WM = new DystopiaUI.WindowManager(this);
GameLoop();
}
示例12: Main
static void Main(string[] args)
{
Log.GlobalLevel = Log.Level.Debug;
RenderWindow app = new RenderWindow(new VideoMode(800, 600), "HP!",
Styles.Default, new ContextSettings(0, 0, 4));
app.SetFramerateLimit(60);
app.Closed += delegate { app.Close(); };
app.SetVisible(true);
app.SetActive(true);
L.I("Assuming assets in \"assets\"");
Assets assets = new Assets("assets");
LoadAnimations(assets);
Level level1 = assets.Level("level1.json");
Game game = new Game(assets, level1);
var view = new View();
int lastFrameTime = Environment.TickCount;
while (app.IsOpen) {
app.DispatchEvents();
float aspect = (float)app.Size.X / app.Size.Y;
float targetWidth = 20, targetHeight = targetWidth / aspect;
view.Reset(new FloatRect(0, 0, targetWidth, targetHeight));
app.SetView(view);
int ticks = Environment.TickCount;
float delta = (ticks - lastFrameTime) / 1000F;
lastFrameTime = ticks;
game.Update(delta);
game.Render(app);
app.Display();
}
}
示例13: Run
public static void Run()
{
Sound.Loop("music/seaponies");
window = new RenderWindow(videomode, title, Styles.Default);
window.Closed += new EventHandler(OnClosed);
window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
window.Resized += new EventHandler<SizeEventArgs>(OnResized);
window.SetIcon(48, 48, new Image("data/tilesheets/pinktaffy48.png").Pixels);
Sprite titleScreen = new Sprite(new Texture(new Image("data/tilesheets/title.png")));
lastTick = DateTime.Now;
View originView = new View(new Vector2f(400, 300), new Vector2f(800, 600));
DateTime starttime = DateTime.Now;
while (window.IsOpen())
{
if (TotalTaffies != 0 && StaticResources.State.Candies >= TotalTaffies){
var t = (DateTime.Now - starttime).TotalMilliseconds/1000;
System.Windows.Forms.MessageBox.Show("You win! Time: " + t);
System.IO.File.AppendAllText("scores.txt", t + "\n");
Environment.Exit(0);
}
DeltaTimeMS = (DateTime.Now - lastTick).TotalMilliseconds;
if (DeltaTimeMS < MSPF)
{
System.Threading.Thread.Sleep((int)(MSPF - DeltaTimeMS));
DeltaTimeMS = MSPF;
}
lastTick = DateTime.Now;
window.DispatchEvents();
window.SetView(originView);
window.Draw(StaticResources.State.Background);
switch (mode)
{
case ExecMode.Title:
window.Draw(titleScreen);
break;
case ExecMode.Intro:
StaticResources.State.Tick();
DialogIfDialog();
break;
case ExecMode.Main:
StaticResources.State.Tick();
if (StaticResources.State.MainCharacter != null){
window.SetView(StaticResources.State.MainCharacter.View);
//window.SetTitle(StaticResources.State.MainCharacter.Position.ToString());
}
foreach (SeaPonyDash.Actor a in StaticResources.State.Actors)
{
if (!a.Hidden && a.OnScreen)
{
//if (a.Type == ActorType.Taffy)
//{
// Sprite b = new Sprite(a.Sprite);
// b.Position = a.Position;
// b.TextureRect = new IntRect(0, 0, 64, 64);
// //works
// window.Draw(b);
//}
//shows nothing on all but a few of the taffy sprites
window.Draw(new Sprite(a.Sprite) { Position = a.Position, TextureRect = a.Sprite.TextureRect });
//System.Windows.Forms.MessageBox.Show(a.Sprite.Position.ToString() + " " + a.Frame.ToXml() + " " + a.Animation.ToXml());
}
else
{
}
}
window.SetView(originView);
Text txt = new Text("Taffies: " + StaticResources.State.Candies + " / " + (TotalTaffies), StaticResources.CelestiaRedux);
txt.CharacterSize = 30;
DialogIfDialog();
window.Draw(txt);
if (StaticResources.State.MainCharacter != null)
window.SetView(StaticResources.State.MainCharacter.View);
break;
case ExecMode.End:
break;
}
//.........这里部分代码省略.........
示例14: draw
public override void draw(GameTime time, RenderWindow window)
{
window.SetView(view);
if (showGrid)
drawGrid(window);
contentManager.draw(time, window);
if (lightLayerEnabled)
lightLayer.draw(window);
guide.draw(window);
}
示例15: 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;
//.........这里部分代码省略.........