当前位置: 首页>>代码示例>>Java>>正文


Java View类代码示例

本文整理汇总了Java中org.jsfml.graphics.View的典型用法代码示例。如果您正苦于以下问题:Java View类的具体用法?Java View怎么用?Java View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


View类属于org.jsfml.graphics包,在下文中一共展示了View类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GameContext

import org.jsfml.graphics.View; //导入依赖的package包/类
/**
 * Creates a new window and initializes resources required by most/all GameStates (e.g. game-configuration)
 * @param width Width of the window
 * @param height Height of the new window
 * @param title Title of the new window
 * @param antiAliasingLevel Level of antiAliasing to use or 0 to disable
 */
public GameContext() {
	try {
		settings = Settings.load(CONFIG_PATH);
		
	} catch (IOException e) {
		throw new Error("Unable to load config-file from '"+CONFIG_PATH.toAbsolutePath().toString()+"': "+e.getMessage(), e);
	}
	
	window = new RenderWindow();
	ContextSettings ctxSettings = new ContextSettings(settings.antiAliasingLevel);
	int style = settings.fullscreen ? WindowStyle.FULLSCREEN : WindowStyle.CLOSE|WindowStyle.TITLEBAR;
	
	window.create(new VideoMode(settings.width, settings.height), WINDOW_TITLE, style, ctxSettings);
	window.setVerticalSyncEnabled(settings.verticalSync);
	
	viewWidth = (int) ((VIEW_HEIGHT/window.getView().getSize().y) * window.getView().getSize().x);
	window.setView(new View(new Vector2f(viewWidth/2, VIEW_HEIGHT/2), new Vector2f(viewWidth, VIEW_HEIGHT)));
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:26,代码来源:GameContext.java

示例2: setStaticView

import org.jsfml.graphics.View; //导入依赖的package包/类
/**
 * Sets the static view to draw GUI & static elements on screen.
 */
public void setStaticView() {
	// Save the game view.
	this.gameView = (View)getWindow().getView();
	
	// Set the static view.
	getWindow().setView(this.staticView);
}
 
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:11,代码来源:Sim.java

示例3: handleInput

import org.jsfml.graphics.View; //导入依赖的package包/类
/**
 * Handles the real-time input from the player.
 * @param dt : elapsed time since last tick
 */
public void handleInput(Time dt) {		
	View view = (View)getWindow().getView();

	// View movement.
	float viewMovementX = 0, viewMovementY = 0;
	
	// View movement via keyboard.
	if(Keyboard.isKeyPressed(Keyboard.Key.LEFT)) {
		viewMovementX -= 400.f;
	}
	else if(Keyboard.isKeyPressed(Keyboard.Key.RIGHT)) {
		viewMovementX += 400.f;
	}
	
	if(Keyboard.isKeyPressed(Keyboard.Key.UP)) {
		viewMovementY -= 400.f;
	}
	else if(Keyboard.isKeyPressed(Keyboard.Key.DOWN)) {
		viewMovementY += 400.f;
	}
	
	// Move the view.
	Vector2f viewMovement = new Vector2f(viewMovementX, viewMovementY);
	viewMovement = Vector2f.mul(viewMovement, dt.asSeconds());
	view.move(viewMovement);
	
	getWindow().setView(view);
}
 
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:33,代码来源:Sim.java

示例4: TextInputPool

import org.jsfml.graphics.View; //导入依赖的package包/类
/**
 * Constructor.
 */
public TextInputPool(RenderWindow window) {
	this.window = window;
	this.fonts = new FontManager();
	this.texts = new HashMap<String, TextInput>();
	this.focusedTextName = "";
	this.customView = new View();
	this.useCustomView = false;
}
 
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:12,代码来源:TextInputPool.java

示例5: main

import org.jsfml.graphics.View; //导入依赖的package包/类
public static void main(String[] args) {

        System.out.println("début du jeu");

    	//Initialisation de la configuration de jeu
    	GameConfig.configKeyBindings();



        Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        int WINDOW_H = (int)tailleEcran.getHeight();
        int WINDOW_W =  (int)tailleEcran.getWidth();

        RenderWindow window1 = new RenderWindow(new VideoMode(WINDOW_W,WINDOW_H), "Projet POO",-1);//-1=fullscreen
        window1.setFramerateLimit(60);
        window1.setKeyRepeatEnabled(true);

        // création d'une vue à partir de la zone rectangulaire du monde 2D à voir
        View view1 = new View(new FloatRect(0, 0, WINDOW_W, WINDOW_H));
        window1.setView(view1);

        //Applications variables
        cScreen[] Screens = new cScreen[7];
        int screen = 0;
        Screens[0] = new BootSplash();
        Screens[1] = new MainMenu();
        Screens[4] = new SelectMode();
        Screens[5] = new SelectPersoLocal();
        Screens[3] = new SelectPerso();
        Screens[2] = new GameLoop();

        while (screen >= 0) {
            screen = Screens[screen].Run(window1);
        }
        System.out.println("fin du jeu");
    }
 
开发者ID:FuriousCatInteractive,项目名称:Super-Shoot-Land,代码行数:37,代码来源:Main.java

示例6: displayBuffer

import org.jsfml.graphics.View; //导入依赖的package包/类
private void displayBuffer(RenderTexture buffer, RenderTarget renderTarget, RenderStates rs, float alpha, float scale) {
	final ConstView cView = renderTarget.getView();
	
	Sprite fadeSprite = new Sprite(buffer.getTexture());
	fadeSprite.setColor(new Color(255, 255, 255, (int) alpha));
	fadeSprite.setScale(scale, scale);

	renderTarget.setView(new View(Vector2f.div(cView.getSize(), 2), cView.getSize()));
	renderTarget.draw(fadeSprite, rs);

	renderTarget.setView(cView);
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:13,代码来源:EffectMapRenderer.java

示例7: enter

import org.jsfml.graphics.View; //导入依赖的package包/类
@Override
public final void enter(IContext newCtx) {
	assert(newCtx instanceof GameContext);
	
	this.ctx = (GameContext) newCtx;
	
	ctx.window.setView(new View(Vector2f.div(ctx.window.getView().getSize(), 2), ctx.window.getView().getSize()));
	
	onStart(ctx);
	firstFrame = true;
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:12,代码来源:GameState.java

示例8: drawImpl

import org.jsfml.graphics.View; //导入依赖的package包/类
@Override
protected void drawImpl(RenderTarget renderTarget) {
	innerHeight = 0;
	for( Element e : children )
		innerHeight = Math.max(innerHeight, e.getPosition().y+e.getHeight());
	
	innerHeight-=getPosition().y;
	
	scrollPos = Math.max(0, Math.min(scrollPos, Math.max(0, innerHeight-getHeight())));
	
	border.setPosition(getPosition());
	renderTarget.draw(border);
	
	View view = (View) renderTarget.getView();
	FloatRect panelRect = new FloatRect(getPosition().x / view.getSize().x,
	(getPosition().y) / view.getSize().y,
	(getWidth()) / view.getSize().x,
	(getHeight()) / view.getSize().y);
	
	View v = new View(new FloatRect(getPosition().x, getPosition().y+scrollPos, getWidth(), getHeight()));
	v.setViewport(panelRect);
	renderTarget.setView(v);
	
	super.drawImpl(renderTarget);
	
	renderTarget.setView(view);

	slider.setPosition(getPosition().x+ getWidth()-WIDTH, getPosition().y+ (scrollPos/Math.max(0, innerHeight-getHeight()))*(getHeight()-LENGTH) );
	renderTarget.draw(scrollBar);
	renderTarget.draw(slider);
	
	for( Overlay o : subOverlays ) {
		o.setOffsetPosition(new Vector2f(0, -scrollPos));
	}
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:36,代码来源:VScrollPanel.java

示例9: drawMap

import org.jsfml.graphics.View; //导入依赖的package包/类
private final void drawMap(RenderTarget rt) {
	final ConstView cView = rt.getView();
	
	rt.setView(new View(new Vector2f(cameraX + cView.getSize().x / 2, cameraY + cView.getSize().y / 2), Vector2f.div(cView.getSize(), zoom)));
	getMap().draw(rt);

	rt.setView(new View(Vector2f.mul(rt.getView().getCenter(), layerPanel.getLayer().parallax), rt.getView().getSize()));
	curser.draw(rt);
	rt.setView(cView);
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:11,代码来源:EditorGameState.java

示例10: updateBuffer

import org.jsfml.graphics.View; //导入依赖的package包/类
private void updateBuffer() {
	if( lastClipState!=base.getClipState() ) {
		Vector2f p = base.getPosition();
		
		buffer.setView(new View(new Vector2f(p.x, p.y), new Vector2f(buffer.getSize().x, buffer.getSize().y)));
		((View) buffer.getView()).setRotation(base.getRotation());
		buffer.clear(Color.TRANSPARENT);
		base.draw(buffer);
		buffer.display();
		
		lastClipState = base.getClipState();
	}
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:14,代码来源:Glow.java

示例11: createView

import org.jsfml.graphics.View; //导入依赖的package包/类
protected ConstView createView( ConstView base ) {
	return new View(new Vector2f(x, y), base.getSize());
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:4,代码来源:Camera.java

示例12: calcLayerView

import org.jsfml.graphics.View; //导入依赖的package包/类
protected final ConstView calcLayerView(float parallax, ConstView baseView) {
	return parallax!=1.f ? new View(Vector2f.mul(baseView.getCenter(), parallax), baseView.getSize()) : baseView;
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:4,代码来源:GameMap.java

示例13: getTransformedView

import org.jsfml.graphics.View; //导入依赖的package包/类
private View getTransformedView() {
	Vector2f ws = ctx.window.getView().getSize();
	View view = new View(Vector2f.mul(new Vector2f(cameraX + ws.x / 2, cameraY + ws.y
			/ 2), layerPanel.getLayer().parallax), Vector2f.div(ws, zoom));
	return view;
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:7,代码来源:EditorGameState.java

示例14: setCustomView

import org.jsfml.graphics.View; //导入依赖的package包/类
/**
 * Sets the custom view to use.
 * 
 * @param v : the view to use while rendering.
 */
public void setCustomView(View v) {
	this.useCustomView = true;
	this.customView = v;
}
 
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:10,代码来源:TextInputPool.java


注:本文中的org.jsfml.graphics.View类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。