当前位置: 首页>>代码示例>>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;未经允许,请勿转载。