本文整理汇总了Java中com.badlogic.gdx.Application类的典型用法代码示例。如果您正苦于以下问题:Java Application类的具体用法?Java Application怎么用?Java Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Application类属于com.badlogic.gdx包,在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.badlogic.gdx.Application; //导入依赖的package包/类
@Before
public void setUp() {
final BitmapFont bitmapFont = mock(BitmapFont.class);
// setup Mock for Game resources
when(mResources.getBackgroundMusic()).thenReturn(mock(Music.class));
when(mResources.getGameOver()).thenReturn(mock(Sound.class));
when(mResources.getFont()).thenReturn(bitmapFont);
when(bitmapFont.getBounds(anyString())).thenReturn(new BitmapFont.TextBounds());
// Mock Gdx lib
Gdx.graphics = mock(Graphics.class);
Gdx.app = mock(Application.class);
mGame.create();
}
示例2: initialise
import com.badlogic.gdx.Application; //导入依赖的package包/类
@Override
public void initialise() {
FallbackFileHandleResolver fallbackFileHandleResolver = new FallbackFileHandleResolver(
new ClasspathFileHandleResolver(), new InternalFileHandleResolver());
assetManager = new AssetManager(fallbackFileHandleResolver);
assetManager.setLogger(new Logger("AssetManager", Application.LOG_ERROR));
assetManager.setLoader(UiTheme.class, new UiThemeLoader(fallbackFileHandleResolver));
assetManager.setLoader(TiledMap.class, new TiledMapLoader(fallbackFileHandleResolver));
addScreen(new LoadingScreen(assetManager));
addScreen(new UATSelectionScreen(assetManager));
addScreen(new BlendingUAT());
addScreen(new ClippingUAT());
addScreen(new GeometryUAT());
addScreen(new GraphicsUAT(assetManager));
addScreen(new TextureRegionUAT());
addScreen(new OrthogonalTiledMapNoCachingUAT(assetManager));
addScreen(new OrthogonalTiledMapWithCachingUAT(assetManager));
addScreen(new IsometricTiledMapUAT(assetManager));
addScreen(new HexagonalTiledMapUAT(assetManager));
addScreen(new ParticleEffectsUAT());
addScreen(new ControllerUAT());
addScreen(new ControllerMapping());
addScreen(new UiUAT(assetManager));
}
示例3: handleInputGame
import com.badlogic.gdx.Application; //导入依赖的package包/类
private void handleInputGame(float deltaTime) {
if (cameraHelper.hasTarget(level.bunnyHead)) {
// Player Movement
if (Gdx.input.isKeyPressed(Keys.LEFT)) {
level.bunnyHead.velocity.x = -level.bunnyHead.terminalVelocity.x;
} else if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
level.bunnyHead.velocity.x = level.bunnyHead.terminalVelocity.x;
} else {
// Execute auto-forward movement on non-desktop platform
if (Gdx.app.getType() != Application.ApplicationType.Desktop) {
level.bunnyHead.velocity.x = level.bunnyHead.terminalVelocity.x;
}
}
// Bunny Jump
if (Gdx.input.isTouched() || Gdx.input.isKeyPressed(Keys.SPACE))
level.bunnyHead.setJumping(true);
else
level.bunnyHead.setJumping(false);
}
}
示例4: setup
import com.badlogic.gdx.Application; //导入依赖的package包/类
@Before
public void setup() {
Gdx.app = mock(Application.class);
engine = mock(PooledEngine.class);
when(engine.createComponent(HealthComponent.class)).thenReturn(new HealthComponent());
when(engine.createComponent(DamageComponent.class)).thenReturn(new DamageComponent());
ServiceLocator.appComponent = mock(AppComponent.class);
when(ServiceLocator.getAppComponent().getAudioService()).thenReturn(mock(AudioService.class));
ServiceLocator.entityComponent = mock(EntityComponent.class);
when(ServiceLocator.getEntityComponent().getEffectTextureFactory()).thenReturn(mock(EffectTextureFactory.class));
entity = mock(Entity.class);
fixture = new EffectComponent();
effect1 = Mockito.spy(BaseEffect.class);
when(effect1.tick(any(PooledEngine.class), any(Entity.class), any(EffectComponent.class), anyFloat())).thenReturn(false, false, false, true);
effect2 = Mockito.spy(BaseEffect.class);
}
示例5: getSetting
import com.badlogic.gdx.Application; //导入依赖的package包/类
public static Setting getSetting() {
return new BooleanSetting(false) {
@Override
public boolean shouldDisplay() {
return Compatibility.get().getApplicationType() == Application.ApplicationType.Desktop;
}
@Override
public void onChange() {
Log.debug("Emptying shader cache");
for (int i = 0; i < shaders.length; i++) {
if (shaders[i] != null)
shaders[i].dispose();
shaders[i] = null;
}
}
};
}
示例6: create
import com.badlogic.gdx.Application; //导入依赖的package包/类
@Override
public void create() {
onDesktop = Gdx.app.getType().equals(Application.ApplicationType.Desktop);
prefs = Gdx.app.getPreferences("io.github.lonamiwebs.klooni.game");
// Load the best match for the skin (depending on the device screen dimensions)
skin = SkinLoader.loadSkin();
// Use only one instance for the theme, so anyone using it uses the most up-to-date
Theme.skin = skin; // Not the best idea
final String themeName = prefs.getString("themeName", "default");
if (Theme.exists(themeName))
theme = Theme.getTheme(themeName);
else
theme = Theme.getTheme("default");
Gdx.input.setCatchBackKey(true); // To show the pause menu
setScreen(new MainMenuScreen(this));
effect = new Effect(prefs.getString("effectName", "vanish"));
}
示例7: init
import com.badlogic.gdx.Application; //导入依赖的package包/类
public static void init(DSGame game) {
OPT = new PreferenceAssist();
if(app_orientation == LANDSCAPE) {
T_HEIGHT = 1080;
T_WIDTH = 1920;
} else {
T_WIDTH = 1080;
T_HEIGHT = 1920;
// T_WIDTH = 720;
// T_HEIGHT = 1280;
}
camera = new OrthographicCamera();
camera.position.set((int)(DS.T_WIDTH/2.0), (int)(DS.T_HEIGHT/2.0), 0);
viewport = new FitViewport(DS.T_WIDTH, DS.T_HEIGHT, camera);
DS.game = game;
sb = new SpriteBatch(150);
Gdx.app.setLogLevel(Application.LOG_DEBUG);
}
示例8: PlatformDistributor
import com.badlogic.gdx.Application; //导入依赖的package包/类
/**
* Creates platform specific object by reflection.
* <p>
* Uses class names given by {@link #getAndroidClassName()} and {@link #getIOSClassName()}
* <p>
* If you need to run project on different platform use {@link #setMockObject(Object)} to polyfill platform object.
*
* @throws PlatformDistributorException Throws when something is wrong with environment
*/
@SuppressWarnings("unchecked")
protected PlatformDistributor() throws PlatformDistributorException
{
String className = null;
if (Gdx.app.getType() == Application.ApplicationType.Android) {
className = getAndroidClassName();
} else if (Gdx.app.getType() == Application.ApplicationType.iOS) {
className = getIOSClassName();
} else if (Gdx.app.getType() == Application.ApplicationType.WebGL) {
className = getWebGLClassName();
} else {
return;
}
try {
Class objClass = ClassReflection.forName(className);
platformObject = (T) ClassReflection.getConstructor(objClass).newInstance();
} catch (ReflectionException e) {
e.printStackTrace();
throw new PlatformDistributorException("Something wrong with environment");
}
}
示例9: getSetting
import com.badlogic.gdx.Application; //导入依赖的package包/类
public static Setting getSetting() {
return new BooleanSetting(false) {
@Override
public boolean shouldDisplay() {
return Compatibility.get().getApplicationType() == Application.ApplicationType.Desktop;
}
@Override
public void onChange() {
Log.debug("Emptying shader cache");
for (int i = 0; i < shaders.length; i++) {
if (shaders[i] != null) shaders[i].dispose();
shaders[i] = null;
}
}
};
}
示例10: consumeCustomData
import com.badlogic.gdx.Application; //导入依赖的package包/类
@Override
public void consumeCustomData(int target) {
if (Gdx.app.getType() == Application.ApplicationType.Android || Gdx.app.getType() == Application.ApplicationType.iOS
|| Gdx.app.getType() == Application.ApplicationType.WebGL) {
if (!Gdx.graphics.supportsExtension("OES_texture_float"))
throw new GdxRuntimeException("Extension OES_texture_float not supported!");
// GLES and WebGL defines texture format by 3rd and 8th argument,
// so to get a float texture one needs to supply GL_RGBA and GL_FLOAT there.
Gdx.gl.glTexImage2D(target, 0, internalFormat, width, height, 0, format, GL20.GL_FLOAT, buffer);
} else {
if (!Gdx.graphics.supportsExtension("GL_ARB_texture_float"))
throw new GdxRuntimeException("Extension GL_ARB_texture_float not supported!");
// in desktop OpenGL the texture format is defined only by the third argument,
// hence we need to use GL_RGBA32F there (this constant is unavailable in GLES/WebGL)
Gdx.gl.glTexImage2D(target, 0, internalFormat, width, height, 0, format, GL20.GL_FLOAT, buffer);
}
}
示例11: touchDown
import com.badlogic.gdx.Application; //导入依赖的package包/类
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
Application.ApplicationType type = Gdx.app.getType();
switch (type) {
case Android:
case iOS:
NhgInput input = pointerInputsMap.get(pointer);
touchDownPointer(input, pointer);
break;
case Desktop:
MouseSourceType sourceType = MouseSourceType.fromButtonCode(button);
NhgInput mouseInput = mouseInputsMap.get(sourceType);
touchDownMouse(mouseInput, sourceType);
break;
}
return false;
}
示例12: touchUp
import com.badlogic.gdx.Application; //导入依赖的package包/类
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
Application.ApplicationType type = Gdx.app.getType();
switch (type) {
case Android:
case iOS:
NhgInput input = pointerInputsMap.get(pointer);
touchUpPointer(input);
break;
case Desktop:
MouseSourceType sourceType = MouseSourceType.fromButtonCode(button);
NhgInput mouseInput = mouseInputsMap.get(sourceType);
touchUpMouse(mouseInput);
break;
}
return false;
}
示例13: main
import com.badlogic.gdx.Application; //导入依赖的package包/类
public static void main(String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.useGL30 = false;
config.width = 1024;
config.height = 768;
config.fullscreen = false;
config.vSyncEnabled = config.fullscreen;
Gdx.app = new LwjglApplication(new QuillysCastleGame(), config);
Gdx.app.setLogLevel(Application.LOG_DEBUG);
// Gdx.app.setLogLevel(Application.LOG_INFO);
// Gdx.app.setLogLevel(Application.LOG_ERROR);
// Gdx.app.setLogLevel(Application.LOG_NONE);
}
示例14: create
import com.badlogic.gdx.Application; //导入依赖的package包/类
@Override
public void create() {
try {
logger.setLevel(Logger.DEBUG);
Gdx.app.setLogLevel(Application.LOG_DEBUG);
Texture.setAssetManager(assets);
spriteBatch = new SpriteBatch();
modelBatch = new ModelBatch();
game.create();
} catch (Exception e) {
logger.error(e.getMessage(), e);
Gdx.app.exit();
}
}
示例15: saveUserData
import com.badlogic.gdx.Application; //导入依赖的package包/类
void saveUserData(UserData userData) {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
String toSave = new Yaml(options).dump(UserData.serialize(userData));
if (Gdx.app.getType() == Application.ApplicationType.Desktop) {
Gdx.files.local("game.save").writeString(toSave, false);
return;
}
try {
loadKey();
byte[] bytes = encrypt(key, toSave.getBytes("UTF-8"));
Gdx.files.local("game.save").writeBytes(bytes, false);
} catch (Exception e) {
Gdx.files.local("game.save").writeString(toSave, false);
}
}