當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。