Java 类com.badlogic.gdx.graphics.g2d.TextureAtlas 实例源码
项目:cocos2d-java
文件:SpriteFrameCache.java
/**
* 读取gdx textureAtlas文件
* @param filePath atlas 文件路径 也可以自定义
* @param atlas
*/
public void addSpriteFrameWithTextureAtlas(String filePath, TextureAtlas atlas) {
if(_atlases.containsKey(filePath)) {
CCLog.debug(this.getClass(), "file loaded : " + filePath);
return;
}
_atlases.put(filePath, atlas);
Array<AtlasRegion> rs = atlas.getRegions();
for(AtlasRegion r : rs) {
TextureRegion ret = _spriteFrames.put(r.name, r);
if(ret != null) {
CCLog.debug(this.getClass(), "region name exists : " + r.name);
}
}
}
项目:libgdx_ui_editor
文件:ImageUtils.java
public BufferedImage extractImage(TextureAtlas.TextureAtlasData atlas, String regionName, int[] splits) {
for (TextureAtlas.TextureAtlasData.Region region : atlas.getRegions()) {
if(region.name.equals(regionName)) {
TextureAtlas.TextureAtlasData.Page page = region.page;
BufferedImage img = null;
try {
img = ImageIO.read(page.textureFile.file());
} catch (IOException e) {
}
region.splits = splits;
return extractNinePatch(img, region);
}
}
return null;
}
项目:libgdx_ui_editor
文件:ImageUtils.java
private BufferedImage extractNinePatch (BufferedImage page, TextureAtlas.TextureAtlasData.Region region) {
BufferedImage splitImage = extractImage(page, region, NINEPATCH_PADDING);
Graphics2D g2 = splitImage.createGraphics();
g2.setColor(Color.BLACK);
// Draw the four lines to save the ninepatch's padding and splits
int startX = region.splits[0] + NINEPATCH_PADDING;
int endX = region.width - region.splits[1] + NINEPATCH_PADDING - 1;
int startY = region.splits[2] + NINEPATCH_PADDING;
int endY = region.height - region.splits[3] + NINEPATCH_PADDING - 1;
if (endX >= startX) g2.drawLine(startX, 0, endX, 0);
if (endY >= startY) g2.drawLine(0, startY, 0, endY);
if (region.pads != null) {
int padStartX = region.pads[0] + NINEPATCH_PADDING;
int padEndX = region.width - region.pads[1] + NINEPATCH_PADDING - 1;
int padStartY = region.pads[2] + NINEPATCH_PADDING;
int padEndY = region.height - region.pads[3] + NINEPATCH_PADDING - 1;
g2.drawLine(padStartX, splitImage.getHeight() - 1, padEndX, splitImage.getHeight() - 1);
g2.drawLine(splitImage.getWidth() - 1, padStartY, splitImage.getWidth() - 1, padEndY);
}
g2.dispose();
return splitImage;
}
项目:SpaceChaos
文件:AtlasAnimationComponent.java
protected void createCachedAnimations(Map<String, Integer> map) {
int i = 0;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
String animationName = entry.getKey();
int frameCounter = entry.getValue();
// calculate duration per frame
float durationPerFrame = this.sumDuration / frameCounter;
// get regions
Array<TextureAtlas.AtlasRegion> regions = this.atlas.findRegions(animationName);
// create animation
Animation<TextureRegion> anim = new Animation<>(durationPerFrame, regions, Animation.PlayMode.LOOP);
// add animation to map
this.animationMap.put(animationName, anim);
i++;
}
}
项目:miniventure
文件:GameCore.java
@Override
public void create () {
entityAtlas = new TextureAtlas("sprites/entities.txt");
tileAtlas = new TextureAtlas("sprites/tiles.txt");
tileConnectionAtlas = new TextureAtlas("sprites/tileconnectmap.txt");
iconAtlas = new TextureAtlas("sprites/icons.txt");
batch = new SpriteBatch();
font = new BitmapFont(); // uses libGDX's default Arial font
for(AtlasRegion region: iconAtlas.getRegions())
icons.put(region.name, region);
game = this;
this.setScreen(new MainMenuScreen());
}
项目:libgdx-crypt-texture
文件:TestCryptTextureAtlas.java
@Override
public void create() {
batch = new SpriteBatch();
font = new BitmapFont();
font.setColor(0, 0, 1, 1);
// Origin
TextureAtlas originTextureAtlas = new TextureAtlas(ORIGIN_PATH + "/test.atlas");
Skin originSkin = new Skin(originTextureAtlas);
originTextureRegion = originSkin.getRegion("badlogic");
// Encrypt
SimpleXorCryptoEncryptor.process("123", "atlas", "encryptedAtlas");
// Decrypt
CryptTextureAtlas cryptTextureAtlas = new CryptTextureAtlas(crypto, ENCRYPTED_PATH + "/test.atlas");
Skin skin = new Skin(cryptTextureAtlas);
decryptTextureRegion = skin.getRegion("badlogic");
}
项目:Polymorph
文件:PolyGame.java
private void initEntities(TextureAtlas textureAtlas) {
final float mobWidth = Polymorph.WORLD_WIDTH/4;
player = new Player(new Vector2(Polymorph.WORLD_WIDTH/2 - mobWidth/2, Polymorph.WORLD_HEIGHT/3-mobWidth),
new Dimension(mobWidth, mobWidth));
slots = new Array<Slot>();
slotPool = new Pool<Slot>() {
@Override
protected Slot newObject() {
return new Slot(new Vector2(SLOT_SPAWN_POINT),
new Vector2(slotVelocity),
new Dimension(mobWidth, mobWidth));
}
};
Dimension mapSize = new Dimension(Polymorph.WORLD_WIDTH, (int)(Polymorph.WORLD_HEIGHT*1.1f));
TextureRegion mapTexture = textureAtlas.findRegion("background");
Map mapFront = new Map(new Vector2(0, 0), mapVelocity, mapSize, mapTexture);
Map mapBack = new Map(new Vector2(0, -mapSize.height + 5), mapVelocity, mapSize, mapTexture);
maps = new Map[]{mapFront, mapBack};
}
项目:Polymorph
文件:Polymorph.java
private void loadAssets() {
InternalFileHandleResolver fileHandler = new InternalFileHandleResolver();
assetManager = new AssetManager(fileHandler);
assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(fileHandler));
assetManager.load(SKIN_PATH, Skin.class);
assetManager.load(MASTER_PATH, TextureAtlas.class);
assetManager.load(FONT_NORMAL_PATH, FreeTypeFontGenerator.class);
assetManager.load(FONT_BOLD_PATH, FreeTypeFontGenerator.class);
assetManager.load(MUSIC_PATH, Music.class);
assetManager.load(MAIN_MENU_MUSIC_PATH, Music.class);
assetManager.load(GOOD_PATH, Sound.class);
assetManager.load(HALF_PATH, Sound.class);
assetManager.load(BAD_PATH, Sound.class);
assetManager.finishLoading();
}
项目:Polymorph
文件:DeathScreen.java
public DeathScreen(Polymorph polymorph,int playerscore) {
AssetManager assetManager = polymorph.getAssetManager();
TextureAtlas textureAtlas = assetManager.get(Polymorph.MASTER_PATH, TextureAtlas.class);
this.polymorph = polymorph;
score=playerscore;
DeathScreenMusic = assetManager.get(Polymorph.MAIN_MENU_MUSIC_PATH);
DeathScreenMusic.setLooping(true);
background = textureAtlas.findRegion("mainmenu"); //TODO make a unique background for the death screen
screenSize = new Dimension(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera = new OrthographicCamera();
camera.setToOrtho(false, screenSize.width, screenSize.height); //change this
batch=new SpriteBatch();
batch.setProjectionMatrix(camera.combined);
stage = new Stage();
stage.clear();
font = new BitmapFont(false);
textureAtlas = assetManager.get(Polymorph.MASTER_PATH, TextureAtlas.class);
initButtons(score,textureAtlas);
Gdx.input.setInputProcessor(stage);
}
项目:Polymorph
文件:DeathScreen.java
public void initButtons(int score,TextureAtlas buttonAtlas) {
Skin buttonSkin = new Skin();
buttonSkin.addRegions(buttonAtlas);
//TODO FIX THIS SHIT INDENTATION
//TODO Long-term fix the magic numbers
ImageButton playButton = new ImageButton(buttonSkin.getDrawable("playbutton"),
buttonSkin.getDrawable("playbutton"));
playButton.setSize(256, 64);
playButton.setPosition(screenSize.width/2-playButton.getWidth()/2,
screenSize.height/2-playButton.getHeight()/2+50);
playButton.addListener(new InputListener() {
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
polymorph.setScreen(new GameScreen(polymorph));
DeathScreenMusic.stop();
return true;
}
});
stage.addActor(playButton);
}
项目:Polymorph
文件:GameScreen.java
private void initHud() {
hud = new Stage(viewport, batch);
Gdx.input.setInputProcessor(new InputMultiplexer(new KeyboardInputHandler(), hud));
//init widgets
ColorButton[] colorButtons = createColorButtons();
final ShapeButton[] shapeButtons = createShapeButtons(colorButtons);
// add widgets to stage
for (ShapeButton shapeButton : shapeButtons) {
hud.addActor(shapeButton);
}
for (ColorButton colorButton : colorButtons) {
hud.addActor(colorButton);
}
TextureAtlas textureAtlas = polymorph.getAssetManager().get(Polymorph.MASTER_PATH, TextureAtlas.class);
hud.addActor(createHealthBar(textureAtlas));
hud.addActor(createPauseButton(textureAtlas));
}
项目:KyperBox
文件:KyperMapLoader.java
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile,
com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) {
Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
try {
root = xml.parse(tmxFile);
Element properties = root.getChildByName("properties");
if (properties != null) {
for (Element property : properties.getChildrenByName("property")) {
String name = property.getAttribute("name");
String value = property.getAttribute("value");
if (name.startsWith("atlas")) {
FileHandle atlasHandle = Gdx.files.internal(value);
dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
}
}
}
} catch (IOException e) {
throw new GdxRuntimeException("Unable to parse .tmx file.");
}
return dependencies;
}
项目:school-game
文件:StoneBarrier.java
/**
* Inititalisiert den NPC.
* Lädt alle Grafiken und Animationen.
*/
@Override
public void onInit()
{
super.onInit();
stoneAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/stone.atlas"));
bigStone = stoneAtlas.findRegion("stone_big");
if (rawObject instanceof RectangleMapObject)
{
RectangleMapObject rectObject = (RectangleMapObject) rawObject;
Rectangle rect = rectObject.getRectangle();
position = new Vector2(rect.getX() + rect.getWidth() / 2f, rect.getY());
startPosition = new Vector2(rect.getX(), rect.getY());
rectShape = Physics.createRectangle(rect.getWidth(), rect.getHeight(), new Vector2(rect.getWidth() / 2f, rect.getHeight() / 2f));
if (activate)
body = createEntityBody(startPosition, rectShape, BodyDef.BodyType.KinematicBody);
} else {
Gdx.app.log("WARNING", "Stone Barrier " + objectId + " must have an RectangleMapObject!");
worldObjectManager.removeObject(this);
}
}
项目:libGdx-xiyou
文件:JumpBall.java
private void init() {
mSkillAtlas = MyGdxGame.assetManager.getTextureAtlas(Constant.FIREBALL_WIDGET);
//升龙斩动画初始化
mRJumpAtkRegions = new TextureAtlas.AtlasRegion[4];
for (int i = 0; i < mRJumpAtkRegions.length - 1; i++) {
mRJumpAtkRegions[i] = new TextureAtlas.AtlasRegion(mSkillAtlas.findRegion("jumpHit" + (i + 1)));
}
mRJumpAtkRegions[3] = new TextureAtlas.AtlasRegion(mSkillAtlas.findRegion("jumpHit3"));
mLJumpAtkRegions = new TextureAtlas.AtlasRegion[4];
for (int i = 0; i < mLJumpAtkRegions.length - 1; i++) {
mLJumpAtkRegions[i] = new TextureAtlas.AtlasRegion(mSkillAtlas.findRegion("jumpHit" + (i + 1)));
mLJumpAtkRegions[i].flip(true, false);
}
mLJumpAtkRegions[3] = mLJumpAtkRegions[2];
mRJumpAtkAni = new Animation(1 / 12f, mRJumpAtkRegions);
mLJumpAtkAni = new Animation(1 / 12f, mLJumpAtkRegions);
}
项目:le-pendu
文件:LePendu.java
@Override
public void create () {
atlas = new TextureAtlas(Gdx.files.internal("LePendu.pack"));
batch = new SpriteBatch();
try {
fileHandle = Gdx.files.internal("dictionnaires/facile.txt");
reader = new BufferedReader(fileHandle.reader());
while ((line = reader.readLine()) != null) easyWords.add(line);
fileHandle = Gdx.files.internal("dictionnaires/normal.txt");
reader = new BufferedReader(fileHandle.reader());
while ((line = reader.readLine()) != null) normalWords.add(line);
fileHandle = Gdx.files.internal("dictionnaires/difficile.txt");
reader = new BufferedReader(fileHandle.reader());
while ((line = reader.readLine()) != null) hardWords.add(line);
} catch (IOException e) {
System.out.println("Chargement des dictionnaires impossible !");
System.out.println(e.getMessage());
Gdx.app.exit();
}
setScreen(new MenuScreen(this));
}
项目:cgc-game
文件:ChaseApp.java
public void preLoad()
{
input = new InputManager(se);
Controllers.addListener(input);
atlas = new TextureAtlas("main.atlas");
titleScreenAtlas = new TextureAtlas("titlescreen.atlas");
menuControlsAtlas = new TextureAtlas("menu.atlas");
menuFont = new BitmapFont(Gdx.files.internal("data/cgcfont.fnt"), atlas.findRegion("cgcfont"), false);
titleFont = new BitmapFont(Gdx.files.internal("data/cgctitlefont.fnt"), atlas.findRegion("cgctitlefont"), false);
sBatch = new SpriteBatch(1625);
shapes = new ShapeRenderer();
tManager = new TweenManager();
FileHandle baseFileHandle = Gdx.files.internal("i18n/CGCLang");
I18NBundle myBundle = I18NBundle.createBundle(baseFileHandle, locale);
lang = myBundle;
ChaseApp.alert("lang loaded");
}
项目:Battle-City-Multiplayer
文件:Assets.java
public static Animation createAnimation(TextureAtlas atlas,
String regionName, float frameDuration, Animation.PlayMode mode) {
ArrayList<TextureRegion> frames = new ArrayList<>();
int idx = 0;
TextureAtlas.AtlasRegion region;
while ((region = atlas.findRegion(regionName, idx)) != null) {
frames.add(region);
idx++;
}
TextureRegion[] regions = new TextureRegion[idx];
Animation anim = new Animation(frameDuration, frames.toArray(regions));
anim.setPlayMode(mode);
return anim;
}
项目:space-travels-3
文件:Explosion.java
public Explosion(float x, float y, float width, float height, TextureAtlas textureAtlas)
{
this.physicsComponent = new PhysicsComponent(
x,
y,
0f,
(height + width) / 4f,
new GameEntityGroup(GameEntityGroup.GroupOverride.NONE),
this.getClass(),
false,
PhysicsComponentType.DYNAMIC);
this.graphicComponent = new AnimatedGraphicComponent(
textureAtlas,
Constants.Visual.EXPLOSION_LIFETIME,
width,
height,
this.physicsComponent,
Animation.PlayMode.NORMAL);
this.sound = AssMan.getGameAssMan().get(AssMan.getAssList().explosionSound);
this.sound.play(SettingsManager.getSettings().volumeFX);
}
项目:space-travels-3
文件:AnimatedGraphicComponent.java
public AnimatedGraphicComponent(
TextureAtlas textureAtlas,
float animationTotalTime,
float width,
float height,
PhysicsComponent physicsComponent,
Animation.PlayMode playMode)
{
super(physicsComponent, width, height);
this.animationTime = Stopwatch.createStarted();
this.textureAtlas = textureAtlas;
this.animation = new Animation(
animationTotalTime / this.textureAtlas.getRegions().size,
this.textureAtlas.getRegions(),
playMode);
}
项目:Teleport-Ball
文件:LoadingScreen.java
private void loadAssets()
{
app.assets.load("atlases/everything1.pack", TextureAtlas.class);
app.assets.load("images/paddlandball/bg-red.png", Texture.class);
app.assets.load("images/paddlandball/bg-orange.png", Texture.class);
app.assets.load("images/paddlandball/bg-blue.png", Texture.class);
app.assets.load("images/paddlandball/bg-green.png", Texture.class);
app.assets.load("images/helpScreen/helpscreen.png", Texture.class);
app.assets.load("images/colors/overlay.png", Texture.class);
app.assets.load("images/backButton/back-up.png", Texture.class);
app.assets.load("images/backButton/back-down.png", Texture.class);
app.assets.load("sounds/kick.wav", Sound.class);
app.assets.load("sounds/a1.mp3", Sound.class);
app.assets.load("sounds/a2.mp3", Sound.class);
app.assets.load("sounds/rip.wav", Sound.class);
app.assets.finishLoading();
}
项目:Teleport-Ball
文件:HelpButton.java
public HelpButton(final Application app, final MenuHud menuHud, final TextureAtlas atlas)
{
drawableUp = new SpriteDrawable(atlas.createSprite("help-up"));
drawableDown = new SpriteDrawable(atlas.createSprite("help-down"));
applyFilter();
button = new ImageButton(drawableUp, drawableDown);
button.addListener(new ClickListener()
{
@Override
public void clicked (InputEvent event, float x, float y)
{
menuHud.removeAllActorsFromStage();
ColorOverlay.enabled = false;
app.setScreen(new HelpScreen(app, atlas));
}
});
}
项目:Teleport-Ball
文件:PlayButton.java
public PlayButton(final Application app, final TextureAtlas atlas)
{
drawableUp = new SpriteDrawable(atlas.createSprite("pb-up"));
drawableDown = new SpriteDrawable(atlas.createSprite("pb-down"));
applyFilter();
button = new ImageButton(drawableUp, drawableDown);
button.addListener(new ClickListener()
{
@Override
public void clicked (InputEvent event, float x, float y)
{
app.setScreen(new GameScreen(app, atlas));
}
});
}
项目:Teleport-Ball
文件:HomeButton.java
public HomeButton(final Application app, final TextureAtlas atlas)
{
drawableUp = new SpriteDrawable(atlas.createSprite("home-up"));
drawableDown = new SpriteDrawable(atlas.createSprite("home-down"));
applyFilter();
button = new ImageButton(drawableUp, drawableDown);
button.addListener(new ClickListener()
{
@Override
public void clicked(InputEvent event, float x, float y)
{
Ball.died = false;
GameScreen.adAlreadyShowed++;
app.setScreen(new MenuScreen(app));
}
});
}
项目:Teleport-Ball
文件:RestartButton.java
public RestartButton(final Player player, final Ball ball, final TextureAtlas atlas)
{
drawableUp = new SpriteDrawable(atlas.createSprite("rb-normal"));
drawableDown = new SpriteDrawable(atlas.createSprite("rb-down"));
applyFilter();
button = new ImageButton(drawableUp, drawableDown);
button.addListener(new ClickListener()
{
@Override
public void clicked(InputEvent event, float x, float y)
{
Ball.died = false;
GameScreen.adAlreadyShowed++;
ball.reset();
player.reset();
}
});
}
项目:Teleport-Ball
文件:RestartHud.java
public RestartHud(final Application app, Viewport viewport, SpriteBatch batch, final Player player, final Ball ball, final TextureAtlas atlas)
{
super(viewport, batch);
gameOverLabel = new GameOverLabel();
restartButton = new RestartButton(player, ball, atlas);
score = new Score();
highScore = new HighScore(app);
homeButton = new HomeButton(app, atlas);
gameOverLabel.getLabel().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 + 350, Align.center);
restartButton.getButton().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 + 100, Align.center);
homeButton.getButton().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 - 25, Align.top);
score.getLabel().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 - 300, Align.center);
highScore.getLabel().setPosition(Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2 - 500, Align.center);
actors.add(gameOverLabel.getLabel());
actors.add(restartButton.getButton());
actors.add(homeButton.getButton());
actors.add(score.getLabel());
actors.add(highScore.getLabel());
addAllActorsToStage();
}
项目:GDefence
文件:SlotActor.java
static ImageButtonStyle createStyle(Skin skin, Item prototype/* slot*/) {
//TextureAtlas icons = LibgdxUtils.assets.get("icons/icons.atlas", TextureAtlas.class);
// TextureAtlas icons = new TextureAtlas(Gdx.files.internal("icons/icons.atlas"));
TextureAtlas icons = GDefence.getInstance().assetLoader.get("icons/icons.atlas", TextureAtlas.class);
TextureRegion image;
if (/*slot.getPrototype()*/prototype != null) {
image = icons.findRegion(prototype.getTextureRegion());
} else {
image = icons.findRegion("nothing");
}
ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class));
style.imageUp = new TextureRegionDrawable(image);
style.imageDown = new TextureRegionDrawable(image);
return style;
}
项目:cachebox3.0
文件:StageManager.java
public static void setMainStage(NamedStage stage) {
mainStage = stage;
if (false && mainStage instanceof ViewManager) {
// add scaled drawable to batch for non throwing exception with scaled drawing!
CompassStyle compassStyle = VisUI.getSkin().get("compassViewStyle", CompassViewStyle.class);
if (compassStyle.arrow != null)
batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.arrow).getRegion()).name);
if (compassStyle.scale != null)
batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.scale).getRegion()).name);
if (compassStyle.frameCompasAlign != null)
batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.frameCompasAlign).getRegion()).name);
if (compassStyle.frameNorthOrient != null)
batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.frameNorthOrient).getRegion()).name);
if (compassStyle.frameUserRotate != null)
batch.registerScaledDrawable(((TextureAtlas.AtlasRegion) ((TextureRegionDrawable) compassStyle.frameUserRotate).getRegion()).name);
}
// add mainStage to input processor
if (inputMultiplexer != null) addNonDoubleInputProzessor(mainStage);
}
项目:gdx-texture-packer-gui
文件:PageAmountMetadataProcessor.java
@Override
public void processPackage(PackProcessingNode node) throws Exception {
PackModel pack = node.getPack();
ProjectModel project = node.getProject();
FileHandle packFileHandle = Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename());
FileHandle imagesDirFileHandle = Gdx.files.absolute(pack.getOutputDir());
TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData(
packFileHandle,
imagesDirFileHandle,
false);
int pageAmount = atlasData.getPages().size;
node.addMetadata(PackProcessingNode.META_ATLAS_PAGES, pageAmount);
System.out.println(pageAmount + " pages");
}
项目:dice-heroes
文件:AddEffectVisualizer.java
@Override public IFuture<Void> visualize(final AddEffect result) {
final Array<TextureAtlas.AtlasRegion> regions = Config.findRegions("animation/effect-" + result.ability.name);
if (regions.size == 0)
return Future.completed();
final WorldObjectView view = visualizer.viewController.getView(result.getTarget());
final AnimationSubView subView = new AnimationSubView(0.1f, regions, Animation.PlayMode.LOOP);
subView.getActor().setPosition(1, 2);
subView.priority = 1;
view.addSubView(subView);
visualizer.viewController.world.dispatcher.add(Creature.REMOVE_EFFECT, new EventListener<EffectEvent>() {
@Override public void handle(EventType<EffectEvent> type, EffectEvent event) {
if (event.effect != result.effectToApply || event.creature != result.creatureToAddEffect)
return;
visualizer.viewController.world.dispatcher.remove(Creature.REMOVE_EFFECT, this);
SoundManager.instance.playMusicAsSound("boss-protection-loss");
subView.getActor().addAction(Actions.alpha(0, DURATION));
subView.getActor().addAction(Actions.delay(DURATION, Actions.run(new Runnable() {
@Override public void run() {
view.removeSubView(subView);
}
})));
}
});
return Future.completed();
}
项目:dice-heroes
文件:TeleportVisualizer.java
private Array<TextureAtlas.AtlasRegion> compose(String name) {
Array<TextureAtlas.AtlasRegion> result = composes.get(name);
if (result == null) {
result = new Array<TextureAtlas.AtlasRegion>(Config.findRegions(name));
Array<TextureAtlas.AtlasRegion> rev = new Array<TextureAtlas.AtlasRegion>(result);
rev.pop();
rev.reverse();
for (int i = 0; i < 1; i++) {
result.add(result.get(result.size - 2));
result.add(result.get(result.size - 2));
}
result.addAll(rev);
composes.put(name, result);
}
return result;
}
项目:gdx-texture-packer-gui
文件:FileSizeMetadataProcessor.java
@Override
public void processPackage(PackProcessingNode node) throws Exception {
PackModel pack = node.getPack();
ProjectModel project = node.getProject();
FileHandle packFileHandle = Gdx.files.absolute(pack.getOutputDir()).child(pack.getCanonicalFilename());
FileHandle imagesDirFileHandle = Gdx.files.absolute(pack.getOutputDir());
TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData(
packFileHandle,
imagesDirFileHandle,
false);
long totalSize = 0; // Bytes
totalSize += packFileHandle.length();
for (TextureAtlas.TextureAtlasData.Page page : atlasData.getPages()) {
long pageSize = page.textureFile.length();
totalSize += pageSize;
}
node.addMetadata(PackProcessingNode.META_FILE_SIZE, totalSize);
System.out.println("Total pack files size is " + totalSize + " bytes");
}
项目:cocos2d-java
文件:CC.java
/**
* 装载atlas对象 会添加到SpriteFrameCache中
* @param packName
*/
public static void LoadAtlas(String packName) {
if(SpriteFrameCache.instance().findTextureAtlas(packName) != null) {
return;
}
TextureAtlas ta = new TextureAtlas(CC.File(packName));
SpriteFrameCache.instance().addSpriteFrameWithTextureAtlas(packName, ta);
}
项目:cocos2d-java
文件:CC.java
public static void LoadAtlas(String packName, String imgPath) {
if(SpriteFrameCache.instance().findTextureAtlas(packName) != null) {
return;
}
TextureAtlas ta = new TextureAtlas(CC.File(packName), CC.File(imgPath));
SpriteFrameCache.instance().addSpriteFrameWithTextureAtlas(packName, ta);
}
项目:cocos2d-java
文件:SpriteFrameCache.java
public void removeSpriteFramesFromTextureAtlas(String filePath) {
TextureAtlas atlas = _atlases.get(filePath);
if(atlas == null) {
CCLog.debug(this.getClass(), "remove atlas not found : " + filePath);
return;
}
Array<AtlasRegion> rs = atlas.getRegions();
for(AtlasRegion r : rs) {
_spriteFrames.remove(r.name);
}
}
项目:cocos2d-java
文件:TextureAtlasTests.java
public void onEnter() {
super.onEnter();
TextureAtlas atlas;
atlas = CC.TextureAtlas("pack.atlas");
Sprite.createWithSpriteFrame(atlas.findRegion("scene_b1")).addTo(this).setPosition(100, 300);
Sprite.createWithSpriteFrame(atlas.findRegion("scene_b2")).addTo(this).setPosition(200, 300);
Sprite.createWithSpriteFrame(atlas.findRegion("scene_b3")).addTo(this).setPosition(300, 300);
Sprite.createWithSpriteFrame(atlas.findRegion("scene_b4")).addTo(this).setPosition(400, 300);
Sprite.createWithSpriteFrame(atlas.findRegion("scene_b5")).addTo(this).setPosition(500, 300);
Sprite.createWithSpriteFrame(atlas.findRegion("scene_b6")).addTo(this).setPosition(600, 300);
}
项目:feup-lpoo-armadillo
文件:Armadillo.java
/**
* {@inheritDoc}
*/
@Override
public void create() {
batch = new SpriteBatch();
assetManager = new AssetManager();
skin1 = new Skin(Gdx.files.internal("appearance/Armadillo.json"), new TextureAtlas("appearance/Armadillo.atlas"));
skin2 = new Skin(Gdx.files.internal("appearance/smallBtn.json"), new TextureAtlas("appearance/smallBtn.atlas"));
loadAssets();
setMusic();
startGame();
}
项目:libgdx-learnlib
文件:Assets.java
public void init(AssetManager assetManager) {
this.assetManager = assetManager;
assetManager.setErrorListener(this);
assetManager.load(TEXTURE_ATLAS_OBJECTS, TextureAtlas.class);
// load sounds
assetManager.load("sounds/jump.wav", Sound.class);
assetManager.load("sounds/jump_with_feather.wav", Sound.class);
assetManager.load("sounds/pickup_coin.wav", Sound.class);
assetManager.load("sounds/pickup_feather.wav", Sound.class);
assetManager.load("sounds/live_lost.wav", Sound.class);
// load music
assetManager.load("music/hair.ogg", Music.class);
assetManager.finishLoading();
Gdx.app.debug(TAG, "# of assets loaded: " + assetManager.getAssetNames().size);
for (String a : assetManager.getAssetNames()) {
Gdx.app.debug(TAG, "asset: " + a);
}
TextureAtlas atlas = assetManager.get(TEXTURE_ATLAS_OBJECTS);
//激活平滑文理过度
for (Texture t : atlas.getTextures()) {
t.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
}
//创建游戏资源对象
bunny = new AssetBunny(atlas);
rock = new AssetRock(atlas);
goldCoin = new AssetGoldCoin(atlas);
feather = new AssetFeather(atlas);
levelDecoration = new AssetLevelDecoration(atlas);
sounds = new AssetSounds(assetManager);
music = new AssetMusic(assetManager);
fonts = new AssetFonts();
}
项目:libgdx-learnlib
文件:Assets.java
public AssetGoldCoin(TextureAtlas atlas) {
goldCoin = atlas.findRegion("item_gold_coin");
// Animation: Gold Coin
// Array<TextureAtlas.AtlasRegion> regions = atlas.findRegions("anim_gold_coin");
// TextureAtlas.AtlasRegion region = regions.first();
// for (int i = 0; i < 10; i++)
// regions.insert(0, region);
// animGoldCoin = new Animation(1.0f / 20.0f, regions,
// Animation.LOOP_PINGPONG);
}
项目:libgdx-learnlib
文件:Assets.java
public AssetLevelDecoration(TextureAtlas atlas) {
cloud01 = atlas.findRegion("cloud01");
cloud02 = atlas.findRegion("cloud02");
cloud03 = atlas.findRegion("cloud03");
mountainLeft = atlas.findRegion("mountain_left");
mountainRight = atlas.findRegion("mountain_right");
waterOverlay = atlas.findRegion("water_overlay");
goal = atlas.findRegion("goal");
carrot = atlas.findRegion("carrot");
}
项目:Parasites-of-HellSpace
文件:Boom.java
public Boom(float x, float y)
{
texture = AssetLoader.assetManager.get("explosion.pack", TextureAtlas.class);
animation = new Animation<TextureRegion>(1/15f, texture.getRegions());
sprite = new Sprite(animation.getKeyFrame(0));
elapsedTime = 0;
sprite.setPosition(x, y);
rotationAngle = MathUtils.random(359);
sprite.setRotation(rotationAngle);
}