當前位置: 首頁>>代碼示例>>Java>>正文


Java Application類代碼示例

本文整理匯總了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();
}
 
開發者ID:OleksandrKucherenko,項目名稱:spacefish,代碼行數:18,代碼來源:SpacefishTests.java

示例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));
}
 
開發者ID:mini2Dx,項目名稱:mini2Dx,代碼行數:27,代碼來源:UATApplication.java

示例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);
    }
}
 
開發者ID:davyjoneswang,項目名稱:libgdx-learnlib,代碼行數:21,代碼來源:WorldController.java

示例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);
}
 
開發者ID:ezet,項目名稱:penguins-in-space,代碼行數:17,代碼來源:EffectComponentTest.java

示例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;
			}
		}
	};
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:19,代碼來源:WorldShaderProvider.java

示例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"));
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:21,代碼來源:Klooni.java

示例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);
    }
 
開發者ID:dsaves,項目名稱:Ponytron,代碼行數:21,代碼來源:DS.java

示例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");
    }
}
 
開發者ID:mk-5,項目名稱:gdx-fireapp,代碼行數:31,代碼來源:PlatformDistributor.java

示例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;
      }
    }
  };
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:18,代碼來源:WorldShaderProvider.java

示例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);
    }
}
 
開發者ID:MovementSpeed,項目名稱:nhglib,代碼行數:21,代碼來源:NhgFloatTextureData.java

示例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;
}
 
開發者ID:MovementSpeed,項目名稱:nhglib,代碼行數:21,代碼來源:InputHandlerOld.java

示例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;
}
 
開發者ID:MovementSpeed,項目名稱:nhglib,代碼行數:21,代碼來源:InputHandlerOld.java

示例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);
   }
 
開發者ID:Quillraven,項目名稱:Quilly-s-Castle,代碼行數:17,代碼來源:DesktopLauncher.java

示例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();
	}
}
 
開發者ID:mrDarkHouse,項目名稱:GDefence,代碼行數:18,代碼來源:LibgdxUtils.java

示例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);
    }
}
 
開發者ID:ratrecommends,項目名稱:dice-heroes,代碼行數:17,代碼來源:UserDataHelper.java


注:本文中的com.badlogic.gdx.Application類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。