Java Code Examples for com.badlogic.gdx.Gdx#files()

The following examples show how to use com.badlogic.gdx.Gdx#files() . 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: GdxDemoActivity.java    From thunderboard-android with Apache License 2.0 6 votes vote down vote up
protected void onResume() {
    Gdx.app = this;
    Gdx.input = this.getInput();
    Gdx.audio = this.getAudio();
    Gdx.files = this.getFiles();
    Gdx.graphics = this.getGraphics();
    Gdx.net = this.getNet();
    this.input.onResume();
    if (this.graphics != null) {
        this.graphics.onResumeGLSurfaceView();
    }

    if (!this.firstResume) {
        this.graphics.resume();
    } else {
        this.firstResume = false;
    }

    this.isWaitingForAudio = true;
    if (this.wasFocusChanged == 1 || this.wasFocusChanged == -1) {
        this.audio.resume();
        this.isWaitingForAudio = false;
    }

    super.onResume();
}
 
Example 2
Source File: TiledObjectTemplateTest.java    From mini2Dx with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void loadMap() throws TiledException {
	Gdx.files = new LwjglFiles();
	Mdx.files = new LibgdxFiles();
	Mdx.graphics = new LibgdxGraphicsUtils();
	Mdx.platformUtils = new LibgdxPlatformUtils() {
		@Override
		public boolean isGameThread() {
			return false;
		}
	};

	FileHandle file = Mdx.files.internal(Thread.currentThread().getContextClassLoader()
			.getResource("orthogonal_tsx.tmx").getFile().replaceAll("%20", " "));
	tiledMap = new TiledMap(file, false);
}
 
Example 3
Source File: TiledMapTest.java    From mini2Dx with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void loadMap() throws TiledException {
	Gdx.files = new LwjglFiles();
	Mdx.files = new LibgdxFiles();
	Mdx.graphics = new LibgdxGraphicsUtils();
	Mdx.platformUtils = new LibgdxPlatformUtils() {
		@Override
		public boolean isGameThread() {
			return false;
		}
	};

	FileHandle file = Mdx.files.internal(Thread.currentThread().getContextClassLoader()
			.getResource("orthogonal.tmx").getFile().replaceAll("%20", " "));
	tiledMap = new TiledMap(file, false);
}
 
Example 4
Source File: TiledCollisionMapperTest.java    From mini2Dx with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void loadMap() throws TiledException {
	Gdx.files = new LwjglFiles();
	Mdx.files = new LibgdxFiles();
	Mdx.graphics = new LibgdxGraphicsUtils();
	Mdx.locks = new JvmLocks();
	Mdx.platformUtils = new LibgdxPlatformUtils() {
		@Override
		public boolean isGameThread() {
			return false;
		}
	};

	FileHandle file = Mdx.files.internal(Thread.currentThread().getContextClassLoader()
			.getResource("orthogonal.tmx").getFile().replaceAll("%20", " "));
	tiledMap = new TiledMap(file, false);
}
 
Example 5
Source File: UiThemeWriter.java    From mini2Dx with Apache License 2.0 6 votes vote down vote up
public static void main(String [] args) {
	Gdx.files = new LwjglFiles();
	Mdx.reflect = new JvmReflection();
	Mdx.files = new LibgdxFiles();
	
	UiTheme theme = new UiTheme();
	theme.setId(UiTheme.DEFAULT_STYLE_ID);
	theme.putFont("default", "example.ttf");
	
	ButtonStyleRuleset buttonRuleset = new ButtonStyleRuleset();
	ButtonStyleRule styleRule = new ButtonStyleRule();
	styleRule.setActionBackground("");
	styleRule.setDisabledBackground("");
	styleRule.setHoverBackground("");
	styleRule.setBackground("");
	
	buttonRuleset.putStyleRule(ScreenSize.XS, styleRule);
	theme.putButtonStyleRuleset(UiTheme.DEFAULT_STYLE_ID, buttonRuleset);
	
	try {
		Mdx.json.toJson(Mdx.files.external("/tmp/theme.json"), theme);
	} catch (SerializationException e) {
		e.printStackTrace();
	}
}
 
Example 6
Source File: DesktopComponentScannerTest.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	Gdx.files = new LwjglFiles();
	Mdx.files = new LibgdxFiles();
	Mdx.reflect = new JvmReflection();
	Mdx.platform = GameWrapper.getPlatform();
	componentScanner = new DesktopComponentScanner();
}
 
Example 7
Source File: DesktopDependencyInjectionTest.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	Gdx.files = new LwjglFiles();
	Mdx.files = new LibgdxFiles();
	Mdx.reflect = new JvmReflection();
	Mdx.platform = GameWrapper.getPlatform();
	Mdx.di = new DependencyInjection(new DesktopComponentScanner());
	Mdx.locks = new JvmLocks();
	Mdx.executor = new LibgdxTaskExecutor(2);
}
 
Example 8
Source File: DesktopPlayerDataTest.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
@Before
  public void setUp() {
      Gdx.files = new LwjglFiles();
Mdx.files = new LibgdxFiles();
      Mdx.reflect = new JvmReflection();
      Mdx.platform = GameWrapper.getPlatform();
      Mdx.di = new DependencyInjection(new DesktopComponentScanner());
      desktopData = new DesktopPlayerData(TEST_IDENTIFIER);
      
      createTestObjects();
  }
 
Example 9
Source File: SharedParserTiledMapTest.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
@Test
public void testSharedParser() throws TiledException {
	Gdx.files = new LwjglFiles();
	Mdx.files = new LibgdxFiles();
	Mdx.graphics = new LibgdxGraphicsUtils();
	Mdx.platformUtils = new LibgdxPlatformUtils() {
		@Override
		public boolean isGameThread() {
			return false;
		}
	};

	TiledParser parser = new TiledParser();

	FileHandle orthogonalFile = Mdx.files.internal(Thread.currentThread().getContextClassLoader()
			.getResource("orthogonal.tmx").getFile().replaceAll("%20", " "));
	FileHandle orthogonalTsxFile = Mdx.files.internal(Thread.currentThread().getContextClassLoader()
			.getResource("orthogonal_tsx.tmx").getFile().replaceAll("%20", " "));
	FileHandle isometricFile = Mdx.files.internal(Thread.currentThread().getContextClassLoader()
			.getResource("isometric.tmx").getFile().replaceAll("%20", " "));

	TiledMap orthogonalTiledMap = new TiledMap(parser, orthogonalFile, false);
	TiledMap orthogonalTsxTiledMap = new TiledMap(parser, orthogonalTsxFile, false);
	TiledMap isometricTiledMap = new TiledMap(parser, isometricFile, false);

	Assert.assertEquals(Orientation.ORTHOGONAL, orthogonalTiledMap.getOrientation());
	Assert.assertEquals(Orientation.ISOMETRIC, isometricTiledMap.getOrientation());

	Assert.assertEquals(Orientation.ORTHOGONAL, orthogonalTsxTiledMap.getOrientation());
	Assert.assertEquals(1, orthogonalTsxTiledMap.getTilesets().size);
}
 
Example 10
Source File: AotWriter.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
public static void main(String [] args) throws IOException {
	Mdx.reflect = new JvmReflection();
	Gdx.files = new LwjglFiles();
	Mdx.files = new LibgdxFiles();

	AotSerializationData.registerClass(UiTheme.class);
	AotSerializationData.registerClass(AnimatedImage.class);
	AotSerializationData.registerClass(Button.class);
	AotSerializationData.registerClass(Checkbox.class);
	AotSerializationData.registerClass(Container.class);
	AotSerializationData.registerClass(CustomUiElement.class);
	AotSerializationData.registerClass(Div.class);
	AotSerializationData.registerClass(FlexRow.class);
	AotSerializationData.registerClass(Image.class);
	AotSerializationData.registerClass(ImageButton.class);
	AotSerializationData.registerClass(Label.class);
	AotSerializationData.registerClass(ParentUiElement.class);
	AotSerializationData.registerClass(ProgressBar.class);
	AotSerializationData.registerClass(RadioButton.class);
	AotSerializationData.registerClass(ScrollBox.class);
	AotSerializationData.registerClass(Select.class);
	AotSerializationData.registerClass(Slider.class);
	AotSerializationData.registerClass(Tab.class);
	AotSerializationData.registerClass(TabButton.class);
	AotSerializationData.registerClass(TabView.class);
	AotSerializationData.registerClass(TextBox.class);
	AotSerializationData.registerClass(TextButton.class);
	AotSerializationData.registerClass(UiElement.class);

	File file = new File("aot-data.txt");
	FileWriter writer = new FileWriter(file);
	AotSerializationData.saveTo(writer);
	writer.close();

	System.out.println("Wrote to " + file.getAbsolutePath());
}
 
Example 11
Source File: GdxDemoActivity.java    From thunderboard-android with Apache License 2.0 4 votes vote down vote up
private void init(ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView) {
    if (this.getVersion() < 8) {
        throw new GdxRuntimeException("LibGDX requires Android API Level 8 or later.");
    } else {
        this.setApplicationLogger(new AndroidApplicationLogger());
        this.graphics = new AndroidGraphics(this, config, (ResolutionStrategy) (config.resolutionStrategy == null ? new FillResolutionStrategy() : config.resolutionStrategy));
        this.input = AndroidInputFactory.newAndroidInput(this, this, this.graphics.view, config);
        this.audio = new AndroidAudio(this, config);
        this.getFilesDir();
        this.files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath());
        this.net = new AndroidNet(this);
        this.listener = listener;
        this.handler = new Handler();
        this.useImmersiveMode = config.useImmersiveMode;
        this.hideStatusBar = config.hideStatusBar;
        this.clipboard = new AndroidClipboard(this);
        this.addLifecycleListener(new LifecycleListener() {
            public void resume() {
            }

            public void pause() {
                audio.pause();
            }

            public void dispose() {
                audio.dispose();
            }
        });
        Gdx.app = this;
        Gdx.input = this.getInput();
        Gdx.audio = this.getAudio();
        Gdx.files = this.getFiles();
        Gdx.graphics = this.getGraphics();
        Gdx.net = this.getNet();
        if (!isForView) {
            try {
                this.requestWindowFeature(1);
            } catch (Exception var8) {
                this.log("AndroidApplication", "Content already displayed, cannot request FEATURE_NO_TITLE", var8);
            }

            this.getWindow().setFlags(1024, 1024);
            this.getWindow().clearFlags(2048);
            this.setContentView(this.graphics.getView(), this.createLayoutParams());
        }

        this.createWakeLock(config.useWakelock);
        this.hideStatusBar(this.hideStatusBar);
        this.useImmersiveMode(this.useImmersiveMode);
        if (this.useImmersiveMode && this.getVersion() >= 19) {
            try {
                Class<?> vlistener = Class.forName("com.badlogic.gdx.backends.android.AndroidVisibilityListener");
                Object o = vlistener.newInstance();
                Method method = vlistener.getDeclaredMethod("createListener", AndroidApplicationBase.class);
                method.invoke(o, this);
            } catch (Exception var7) {
                this.log("AndroidApplication", "Failed to create AndroidVisibilityListener", var7);
            }
        }

    }
}
 
Example 12
Source File: PrototypeBeanTest.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	executorService = Executors.newFixedThreadPool(1);

	Gdx.files = new LwjglFiles();
	Mdx.files = new LibgdxFiles();
	Mdx.reflect = new JvmReflection();
	Mdx.platform = GameWrapper.getPlatform();
	Mdx.di = new DependencyInjection(new DesktopComponentScanner());
	Mdx.executor = new TaskExecutor() {
		@Override
		public void dispose() {

		}

		@Override
		public void update(float delta) {

		}

		@Override
		public void execute(Runnable runnable) {
			executorService.submit(runnable);
		}

		@Override
		public AsyncFuture submit(Runnable runnable) {
			executorService.submit(runnable);
			return null;
		}

		@Override
		public <T> AsyncResult<T> submit(Callable<T> callable) {
			executorService.submit(callable);
			return null;
		}

		@Override
		public void submit(FrameSpreadTask task) {

		}

		@Override
		public void setMaxFrameTasksPerFrame(int max) {

		}
	};


	prototype = new TestPrototypeBean();
	prototype.setIntField(100);

	bean = new PrototypeBean(prototype);
	executorService.submit(bean);
}