Skip to content

Instantly share code, notes, and snippets.

@cypherdare
cypherdare / Simple.java
Created August 10, 2020 03:17
Minimal LibGDX FPS counter
package com.cyphercove.example;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
@cypherdare
cypherdare / LifecycleStateAndroidApplication.java
Last active June 6, 2020 22:40
Attempt at fixing deadlocks by using androidx lifecycle state to abstract synchronization
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@cypherdare
cypherdare / flagUnwrapper.kt
Created February 1, 2020 16:10
Unpacks the flags of an Int by name
package com.cyphercove.flagunwrapper
import java.lang.reflect.Modifier
import kotlin.reflect.KClass
/** Return a set of String field names for flags used in the input value.
*
* Usage:
* ```
* Log.d("Flags", unwrapFlags(WindowManager.LayoutParams::class, 2097152).joinToString())
@cypherdare
cypherdare / MyPacker.java
Created December 2, 2016 13:49
Example of using staging directory for texture packing
import com.badlogic.gdx.tools.FileProcessor;
import com.badlogic.gdx.tools.texturepacker.TexturePacker;
import com.cyphercove.cavecat.Assets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
import java.io.File;
import java.util.Collection;
@cypherdare
cypherdare / MyGdxGame.java
Created March 13, 2016 19:28
Example of enter and exit called on clicked button
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
/*******************************************************************************
* Copyright 2016 Cypher Cove LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@cypherdare
cypherdare / AtlasGenerator.java
Created December 29, 2015 20:08
Libgdx texture packing with gifs
/*******************************************************************************
* Copyright 2015 Cypher Cove LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software