Java Code Examples for com.watabou.noosa.Game#width()
The following examples show how to use
com.watabou.noosa.Game#width() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShatteredPixelDungeon.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override public void resize(int width, int height) { if (scene instanceof PixelScene && (height != Game.height || width != Game.width)) { ((PixelScene) scene).saveWindows(); } super.resize(width, height); Graphics.DisplayMode mode = Gdx.graphics.getDisplayMode(); boolean maximized = width >= mode.width || height >= mode.height; if (!maximized && !SPDSettings.fullscreen()){ SPDSettings.put(SPDSettings.KEY_WINDOW_WIDTH, width); SPDSettings.put(SPDSettings.KEY_WINDOW_HEIGHT, height); } }
Example 2
Source File: InputHandler.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public synchronized boolean touchUp(int screenX, int screenY, int pointer, int button) { screenX /= (Game.dispWidth / (float)Game.width); screenY /= (Game.dispHeight / (float)Game.height); PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, false)); return true; }
Example 3
Source File: Window.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public void resize( int w, int h ) { this.width = w; this.height = h; chrome.size( width + chrome.marginHor(), height + chrome.marginVer() ); camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width() - camera.screenWidth()) / 2; camera.y = (int)(Game.height() - camera.screenHeight()) / 2; }
Example 4
Source File: PixelScene.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
PixelCamera(float zoom) { super( (int) (Game.width() - Math.ceil(Game.width() / zoom) * zoom) / 2, (int) (Game.height() - Math.ceil(Game.height() / zoom)* zoom) / 2, (int) Math.ceil(Game.width() / zoom), (int) Math.ceil(Game.height() / zoom), zoom); }
Example 5
Source File: Window.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public void resize( int w, int h ) { this.width = w; this.height = h; chrome.size( width + chrome.marginHor(), height + chrome.marginVer() ); camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; camera.y += yOffset * camera.zoom; shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height ); }
Example 6
Source File: Window.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public void resize( int w, int h ) { this.width = w; this.height = h; chrome.size( width + chrome.marginHor(), height + chrome.marginVer() ); camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; camera.y += yOffset * camera.zoom; shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height ); }
Example 7
Source File: InputHandler.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public synchronized boolean touchDragged(int screenX, int screenY, int pointer) { screenX /= (Game.dispWidth / (float)Game.width); screenY /= (Game.dispHeight / (float)Game.height); PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, true)); return true; }
Example 8
Source File: InputHandler.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public synchronized boolean touchDown(int screenX, int screenY, int pointer, int button) { screenX /= (Game.dispWidth / (float)Game.width); screenY /= (Game.dispHeight / (float)Game.height); PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, true)); return true; }
Example 9
Source File: Window.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public void resize( int w, int h ) { this.width = w; this.height = h; chrome.size( width + chrome.marginHor(), height + chrome.marginVer() ); camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height ); }
Example 10
Source File: PixelScene.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public PixelCamera( float zoom ) { super( (int)(Game.width - Math.ceil( Game.width / zoom ) * zoom) / 2, (int)(Game.height - Math.ceil( Game.height / zoom ) * zoom) / 2, (int)Math.ceil( Game.width / zoom ), (int)Math.ceil( Game.height / zoom ), zoom ); fullScreen = true; }
Example 11
Source File: Window.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public void resize( int w, int h ) { this.width = w; this.height = h; chrome.size( width + chrome.marginHor(), height + chrome.marginVer() ); camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height ); }
Example 12
Source File: PixelScene.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public PixelCamera( float zoom ) { super( (int)(Game.width - Math.ceil( Game.width / zoom ) * zoom) / 2, (int)(Game.height - Math.ceil( Game.height / zoom ) * zoom) / 2, (int)Math.ceil( Game.width / zoom ), (int)Math.ceil( Game.height / zoom ), zoom ); }
Example 13
Source File: Window.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
public void resize( int w, int h ) { this.width = w; this.height = h; chrome.size( width + chrome.marginHor(), height + chrome.marginVer() ); camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height ); }
Example 14
Source File: PixelScene.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
public PixelCamera( float zoom ) { super( (int)(Game.width - Math.ceil( Game.width / zoom ) * zoom) / 2, (int)(Game.height - Math.ceil( Game.height / zoom ) * zoom) / 2, (int)Math.ceil( Game.width / zoom ), (int)Math.ceil( Game.height / zoom ), zoom ); }
Example 15
Source File: PixelScene.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); GameScene.scene = null; float minWidth, minHeight; if (YetAnotherPixelDungeon.landscape()) { minWidth = MIN_WIDTH_L; minHeight = MIN_HEIGHT_L; } else { minWidth = MIN_WIDTH_P; minHeight = MIN_HEIGHT_P; } defaultZoom = (int)Math.ceil( Game.density * 2.5 ); while (( Game.width / defaultZoom < minWidth || Game.height / defaultZoom < minHeight ) && defaultZoom > 1) { defaultZoom--; } if (YetAnotherPixelDungeon.scaleUp()) { while ( Game.width / (defaultZoom + 1) >= minWidth && Game.height / (defaultZoom + 1) >= minHeight) { defaultZoom++; } } minZoom = 1; maxZoom = defaultZoom * 2; Camera.reset( new PixelCamera( defaultZoom ) ); float uiZoom = defaultZoom; uiCamera = Camera.createFullscreen( uiZoom ); Camera.add( uiCamera ); if (font1x == null) { // 3x5 (6) font1x = Font.colorMarked( BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL ); font1x.baseLine = 6; font1x.tracking = -1; // 5x8 (10) font15x = Font.colorMarked( BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL ); font15x.baseLine = 9; font15x.tracking = -1; // 6x10 (12) font2x = Font.colorMarked( BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL ); font2x.baseLine = 11; font2x.tracking = -1; // 7x12 (15) font25x = Font.colorMarked( BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL ); font25x.baseLine = 13; font25x.tracking = -1; // 9x15 (18) font3x = Font.colorMarked( BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL ); font3x.baseLine = 17; font3x.tracking = -2; } }
Example 16
Source File: PixelScene.java From pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); GameScene.scene = null; float minWidth, minHeight; if (PixelDungeon.landscape()) { minWidth = MIN_WIDTH_L; minHeight = MIN_HEIGHT_L; } else { minWidth = MIN_WIDTH_P; minHeight = MIN_HEIGHT_P; } defaultZoom = (int)Math.ceil( Game.density * 2.5 ); while (( Game.width / defaultZoom < minWidth || Game.height / defaultZoom < minHeight ) && defaultZoom > 1) { defaultZoom--; } if (PixelDungeon.scaleUp()) { while ( Game.width / (defaultZoom + 1) >= minWidth && Game.height / (defaultZoom + 1) >= minHeight) { defaultZoom++; } } minZoom = 1; maxZoom = defaultZoom * 2; Camera.reset( new PixelCamera( defaultZoom ) ); float uiZoom = defaultZoom; uiCamera = Camera.createFullscreen( uiZoom ); Camera.add( uiCamera ); if (font1x == null) { // 3x5 (6) font1x = Font.colorMarked( BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL ); font1x.baseLine = 6; font1x.tracking = -1; // 5x8 (10) font15x = Font.colorMarked( BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL ); font15x.baseLine = 9; font15x.tracking = -1; // 6x10 (12) font2x = Font.colorMarked( BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL ); font2x.baseLine = 11; font2x.tracking = -1; // 7x12 (15) font25x = Font.colorMarked( BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL ); font25x.baseLine = 13; font25x.tracking = -1; // 9x15 (18) font3x = Font.colorMarked( BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL ); font3x.baseLine = 17; font3x.tracking = -2; } }
Example 17
Source File: PixelScene.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); GameScene.scene = null; float minWidth, minHeight; if (SPDSettings.landscape()) { minWidth = MIN_WIDTH_L; minHeight = MIN_HEIGHT_L; } else { minWidth = MIN_WIDTH_P; minHeight = MIN_HEIGHT_P; } maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight); defaultZoom = SPDSettings.scale(); if (defaultZoom < Math.ceil( Game.density * 2 ) || defaultZoom > maxDefaultZoom){ defaultZoom = (int)Math.round((Math.ceil( Game.density * 2 ) + maxDefaultZoom)/2); while (( Game.width / defaultZoom < minWidth || Game.height / defaultZoom < minHeight ) && defaultZoom > 1) { defaultZoom--; } } minZoom = 1; maxZoom = defaultZoom * 2; Camera.reset( new PixelCamera( defaultZoom ) ); float uiZoom = defaultZoom; uiCamera = Camera.createFullscreen( uiZoom ); Camera.add( uiCamera ); if (pixelFont == null) { // 3x5 (6) pixelFont = Font.colorMarked( BitmapCache.get( Assets.PIXELFONT), 0x00000000, BitmapText.Font.LATIN_FULL ); pixelFont.baseLine = 6; pixelFont.tracking = -1; } }
Example 18
Source File: AndroidPlatformSupport.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public void updateDisplaySize(){ if (SPDSettings.landscape() != null) { AndroidGame.instance.setRequestedOrientation( SPDSettings.landscape() ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT ); } if (AndroidGame.view.getMeasuredWidth() == 0 || AndroidGame.view.getMeasuredHeight() == 0) return; Game.dispWidth = AndroidGame.view.getMeasuredWidth(); Game.dispHeight = AndroidGame.view.getMeasuredHeight(); boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N || !AndroidGame.instance.isInMultiWindowMode(); if (fullscreen && SPDSettings.landscape() != null && (Game.dispWidth >= Game.dispHeight) != SPDSettings.landscape()){ int tmp = Game.dispWidth; Game.dispWidth = Game.dispHeight; Game.dispHeight = tmp; } float dispRatio = Game.dispWidth / (float)Game.dispHeight; float renderWidth = dispRatio > 1 ? PixelScene.MIN_WIDTH_L : PixelScene.MIN_WIDTH_P; float renderHeight = dispRatio > 1 ? PixelScene.MIN_HEIGHT_L : PixelScene.MIN_HEIGHT_P; //force power saver in this case as all devices must run at at least 2x scale. if (Game.dispWidth < renderWidth*2 || Game.dispHeight < renderHeight*2) SPDSettings.put( SPDSettings.KEY_POWER_SAVER, true ); if (SPDSettings.powerSaver() && fullscreen){ int maxZoom = (int)Math.min(Game.dispWidth/renderWidth, Game.dispHeight/renderHeight); renderWidth *= Math.max( 2, Math.round(1f + maxZoom*0.4f)); renderHeight *= Math.max( 2, Math.round(1f + maxZoom*0.4f)); if (dispRatio > renderWidth / renderHeight){ renderWidth = renderHeight * dispRatio; } else { renderHeight = renderWidth / dispRatio; } final int finalW = Math.round(renderWidth); final int finalH = Math.round(renderHeight); if (finalW != Game.width || finalH != Game.height){ AndroidGame.instance.runOnUiThread(new Runnable() { @Override public void run() { AndroidGame.view.getHolder().setFixedSize(finalW, finalH); } }); } } else { AndroidGame.instance.runOnUiThread(new Runnable() { @Override public void run() { AndroidGame.view.getHolder().setSizeFromLayout(); } }); } }
Example 19
Source File: PixelScene.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); GameScene.scene = null; float minWidth, minHeight; if (ShatteredPixelDungeon.landscape()) { minWidth = MIN_WIDTH_L; minHeight = MIN_HEIGHT_L; } else { minWidth = MIN_WIDTH_P; minHeight = MIN_HEIGHT_P; } defaultZoom = (int)Math.ceil( Game.density * 2.5 ); while (( Game.width / defaultZoom < minWidth || Game.height / defaultZoom < minHeight ) && defaultZoom > 1) { defaultZoom--; } while ( Game.width / (defaultZoom + 1) >= minWidth && Game.height / (defaultZoom + 1) >= minHeight) { defaultZoom++; } minZoom = 1; maxZoom = defaultZoom * 2; Camera.reset( new PixelCamera( defaultZoom ) ); float uiZoom = defaultZoom; uiCamera = Camera.createFullscreen( uiZoom ); Camera.add( uiCamera ); if (font1x == null) { // 3x5 (6) font1x = Font.colorMarked( BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL ); font1x.baseLine = 6; font1x.tracking = -1; // 5x8 (10) font15x = Font.colorMarked( BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL ); font15x.baseLine = 9; font15x.tracking = -1; // 6x10 (12) font2x = Font.colorMarked( BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL ); font2x.baseLine = 11; font2x.tracking = -1; // 7x12 (15) font25x = Font.colorMarked( BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL ); font25x.baseLine = 13; font25x.tracking = -1; // 9x15 (18) font3x = Font.colorMarked( BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL ); font3x.baseLine = 17; font3x.tracking = -2; } }
Example 20
Source File: Ads.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
private static boolean isSmallScreen() { return (Game.width() < 400 || Game.height() < 400); }