mirror of
https://github.com/SFML/SFML.git
synced 2024-11-29 06:41:05 +08:00
* view sample is compilable
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1355 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
bf539551b9
commit
3fa986f94e
@ -17,7 +17,7 @@ void main()
|
|||||||
Sprite background = new Sprite(new Image("Data/background.jpg"));
|
Sprite background = new Sprite(new Image("Data/background.jpg"));
|
||||||
|
|
||||||
Font f = new Font("Data/cheeseburger.ttf");
|
Font f = new Font("Data/cheeseburger.ttf");
|
||||||
String str = new String("Create a selection of the background with your mouse.\nPress Enter to zoom to this selection.\nPress Escape to return to the default view."c, f);
|
Text str = new Text("Create a selection of the background with your mouse.\nPress Enter to zoom to this selection.\nPress Escape to return to the default view."c, f);
|
||||||
|
|
||||||
while (window.isOpened())
|
while (window.isOpened())
|
||||||
{
|
{
|
||||||
@ -25,38 +25,38 @@ void main()
|
|||||||
|
|
||||||
while (window.getEvent(evt))
|
while (window.getEvent(evt))
|
||||||
{
|
{
|
||||||
if ( evt.Type == Event.EventType.MOUSEBUTTONPRESSED &&
|
if ( evt.Type == EventType.MouseButtonPressed &&
|
||||||
evt.MouseButton.Button == MouseButtons.LEFT)
|
evt.MouseButton.Button == MouseButtons.Left)
|
||||||
{
|
{
|
||||||
top = window.convertCoords(input.getMouseX(), input.getMouseY());
|
top = window.convertCoords(input.getMouseX(), input.getMouseY());
|
||||||
mousePressed = true;
|
mousePressed = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ( evt.Type == Event.EventType.MOUSEBUTTONRELEASED &&
|
else if ( evt.Type == EventType.MouseButtonReleased &&
|
||||||
evt.MouseButton.Button == MouseButtons.LEFT)
|
evt.MouseButton.Button == MouseButtons.Left)
|
||||||
{
|
{
|
||||||
mousePressed = false;
|
mousePressed = false;
|
||||||
}
|
}
|
||||||
else if ( evt.Type == Event.EventType.MOUSEMOVED &&
|
else if ( evt.Type == EventType.MouseMoved &&
|
||||||
mousePressed)
|
mousePressed)
|
||||||
{
|
{
|
||||||
Vector2f bottom = window.convertCoords(input.getMouseX(), input.getMouseY());
|
Vector2f bottom = window.convertCoords(input.getMouseX(), input.getMouseY());
|
||||||
bound = new Rect!(float)(top.x, top.y, bottom.x, bottom.y);
|
bound = FloatRect(top.x, top.y, bottom.x, bottom.y);
|
||||||
s = Shape.rectangle(top.x, top.y, bottom.x, bottom.y, Color(0, 0, 0, 0), 1, Color.BLACK);
|
s = Shape.rectangle(top.x, top.y, bottom.x, bottom.y, Color(0, 0, 0, 0), 1, Color.BLACK);
|
||||||
}
|
}
|
||||||
else if ( evt.Type == Event.EventType.KEYPRESSED &&
|
else if ( evt.Type == EventType.KeyPressed &&
|
||||||
evt.Key.Code == KeyCode.RETURN)
|
evt.Key.Code == KeyCode.Return)
|
||||||
{
|
{
|
||||||
if (bound !is null)
|
if (bound != FloatRect())
|
||||||
window.setView(new View(bound));
|
window.setView(new View(bound));
|
||||||
s = null;
|
s = null;
|
||||||
}
|
}
|
||||||
else if ( evt.Type == Event.EventType.KEYPRESSED &&
|
else if ( evt.Type == EventType.KeyPressed &&
|
||||||
evt.Key.Code == KeyCode.ESCAPE)
|
evt.Key.Code == KeyCode.Escape)
|
||||||
{
|
{
|
||||||
window.setView(window.getDefaultView());
|
window.setView(window.getDefaultView());
|
||||||
}
|
}
|
||||||
else if ( evt.Type == Event.EventType.CLOSED)
|
else if ( evt.Type == EventType.Closed)
|
||||||
window.close();
|
window.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user