com.badlogic.gdx.graphics.g2d.TextureRegion Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g2d.TextureRegion. 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: Animation.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public void drawShadow(PaletteIndexedBatch batch, Layer layer, float x, float y) {
  if (frame >= numFrames) {
    return;
  }

  int d = direction;
  int f = frame;

  DC dc    = layer.dc;
  BBox box = dc.getBox(d, f);

  SHADOW_TRANSFORM.idt();
  SHADOW_TRANSFORM.preTranslate(box.xMin, -(box.yMax / 2));
  SHADOW_TRANSFORM.preShear(-1.0f, 0);
  SHADOW_TRANSFORM.preTranslate(x, y);
  SHADOW_TRANSFORM.scale(1, 0.5f);

  if (layer.regions[d] == null) layer.load(d);
  TextureRegion region = layer.regions[d][f];
  if (region.getTexture().getTextureObjectHandle() == 0) return;
  batch.draw(region, region.getRegionWidth(), region.getRegionHeight(), SHADOW_TRANSFORM);
}
 
Example #2
Source File: SmartFontGenerator.java    From gdx-proto with Apache License 2.0 6 votes vote down vote up
/** Convenience method for generating a font, and then writing the fnt and png files.
 * Writing a generated font to files allows the possibility of only generating the fonts when they are missing, otherwise
 * loading from a previously generated file.
 * @param fontFile
 * @param fontSize
 */
private BitmapFont generateFontWriteFiles(String fontName, FileHandle fontFile, int fontSize, int pageWidth, int pageHeight) {
	FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);

	PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 2, false);
	FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(fontSize, FreeTypeFontGenerator.DEFAULT_CHARS, false, packer);
	Array<PixmapPacker.Page> pages = packer.getPages();
	TextureRegion[] texRegions = new TextureRegion[pages.size];
	for (int i=0; i<pages.size; i++) {
		PixmapPacker.Page p = pages.get(i);
		Texture tex = new Texture(new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false, true)) {
			@Override
			public void dispose () {
				super.dispose();
				getTextureData().consumePixmap().dispose();
			}
		};
		tex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
		texRegions[i] = new TextureRegion(tex);
	}
	BitmapFont font = new BitmapFont(fontData, texRegions, false);
	saveFontToFile(font, fontSize, fontName, packer);
	generator.dispose();
	packer.dispose();
	return font;
}
 
Example #3
Source File: Animations.java    From ud406 with MIT License 6 votes vote down vote up
private void drawRegionCentered(SpriteBatch batch, TextureRegion region, float x, float y) {
    batch.draw(
            region.getTexture(),
            x - region.getRegionWidth() / 2,
            y - region.getRegionHeight() / 2,
            0,
            0,
            region.getRegionWidth(),
            region.getRegionHeight(),
            1,
            1,
            0,
            region.getRegionX(),
            region.getRegionY(),
            region.getRegionWidth(),
            region.getRegionHeight(),
            false,
            false);
}
 
Example #4
Source File: Polyline.java    From talos with Apache License 2.0 6 votes vote down vote up
public void draw(Batch batch, TextureRegion region, float x, float y) {
    if(batch instanceof PolygonBatch) {
        PolygonBatch polygonSpriteBatch = (PolygonBatch) batch;
        this.batch = polygonSpriteBatch;

        updatePointPositions(x, y);

        for(int i = 0; i < points.size - 1; i++) {
            // extrude each point
            extrudePoint(region, i, 0);
            extrudePoint(region, i, 1);

            // creating indexes
            indexes[i * 6] =     (short) (i * 4);
            indexes[i * 6 + 1] = (short) (i * 4 + 1);
            indexes[i * 6 + 2] = (short) (i * 4 + 3);
            indexes[i * 6 + 3] = (short) (i * 4);
            indexes[i * 6 + 4] = (short) (i * 4 + 3);
            indexes[i * 6 + 5] = (short) (i * 4 + 2);

        }

        // do the actual drawing
        polygonSpriteBatch.draw(region.getTexture(), vertices, 0, vertices.length, indexes, 0, indexes.length);
    }
}
 
Example #5
Source File: FallingObjectFactory.java    From FruitCatcher with Apache License 2.0 6 votes vote down vote up
public FallingObject getFruit() {
    TextureRegion [] textureRegions = new TextureRegion[1];
    int fruitType = MathUtils.random(0, imageProvider.getFruitsCount() - 1);
    textureRegions[0] =  imageProvider.getFruit(fruitType);
    
    boolean inSeason = FruitType.isInSeason(fruitType, season);
    FallingObjectState state = new FallingObjectState();
    if (inSeason) {
    	state.setType(FallingObjectType.SeasonalFruit);
    }
    else {
    	state.setType(FallingObjectType.Fruit);
    }
    state.setIndex(fruitType);
    return new FallingObject(imageProvider, textureRegions, 
                             state);
}
 
Example #6
Source File: Skin.java    From gdx-skineditor with Apache License 2.0 6 votes vote down vote up
public <T> T get(String name, Class<T> type) {
	if (name == null)
		throw new IllegalArgumentException("name cannot be null.");
	if (type == null)
		throw new IllegalArgumentException("type cannot be null.");

	if (type == Drawable.class)
		return (T) getDrawable(name);
	if (type == TextureRegion.class)
		return (T) getRegion(name);
	if (type == NinePatch.class)
		return (T) getPatch(name);
	if (type == Sprite.class)
		return (T) getSprite(name);

	ObjectMap<String, Object> typeResources = resources.get(type);
	if (typeResources == null)
		throw new GdxRuntimeException("No " + type.getName() + " registered with name: " + name);
	Object resource = typeResources.get(name);
	if (resource == null)
		throw new GdxRuntimeException("No " + type.getName() + " registered with name: " + name);
	return (T) resource;
}
 
Example #7
Source File: Utils.java    From ud406 with MIT License 6 votes vote down vote up
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) {
    batch.draw(
            region.getTexture(),
            x,
            y,
            0,
            0,
            region.getRegionWidth(),
            region.getRegionHeight(),
            1,
            1,
            0,
            region.getRegionX(),
            region.getRegionY(),
            region.getRegionWidth(),
            region.getRegionHeight(),
            false,
            false);
}
 
Example #8
Source File: Utils.java    From ud406 with MIT License 6 votes vote down vote up
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) {
    batch.draw(
            region.getTexture(),
            x,
            y,
            0,
            0,
            region.getRegionWidth(),
            region.getRegionHeight(),
            1,
            1,
            0,
            region.getRegionX(),
            region.getRegionY(),
            region.getRegionWidth(),
            region.getRegionHeight(),
            false,
            false);
}
 
Example #9
Source File: Animations.java    From ud406 with MIT License 6 votes vote down vote up
private void drawRegionCentered(SpriteBatch batch, TextureRegion region, float x, float y) {
    batch.draw(
            region.getTexture(),
            x - region.getRegionWidth() / 2,
            y - region.getRegionHeight() / 2,
            0,
            0,
            region.getRegionWidth(),
            region.getRegionHeight(),
            1,
            1,
            0,
            region.getRegionX(),
            region.getRegionY(),
            region.getRegionWidth(),
            region.getRegionHeight(),
            false,
            false);
}
 
Example #10
Source File: Utils.java    From ud406 with MIT License 6 votes vote down vote up
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) {
    batch.draw(
            region.getTexture(),
            x,
            y,
            0,
            0,
            region.getRegionWidth(),
            region.getRegionHeight(),
            1,
            1,
            0,
            region.getRegionX(),
            region.getRegionY(),
            region.getRegionWidth(),
            region.getRegionHeight(),
            false,
            false);
}
 
Example #11
Source File: SkinNoteDistributionGraph.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
public SkinNoteDistributionGraph(Pixmap[] chips, int type, int delay, int backTexOff, int orderReverse, int noGap) {
	this.chips = chips;
	this.type = type;
	this.isBackTexOff = backTexOff == 1;
	this.delay = delay;
	this.isOrderReverse = orderReverse == 1;
	this.isNoGap = noGap == 1;
	pastNotes = 0;

	Pixmap bp = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
	bp.drawPixel(0, 0, Color.toIntBits(255, 128, 255, 128));
	startcursor = new TextureRegion(new Texture(bp));
	bp.dispose();
	bp = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
	bp.drawPixel(0, 0, Color.toIntBits(255, 128, 128, 255));
	endcursor = new TextureRegion(new Texture(bp));
	bp.dispose();
	bp = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
	bp.drawPixel(0, 0, Color.toIntBits(255, 255, 255, 255));
	nowcursor = new TextureRegion(new Texture(bp));
	bp.dispose();

}
 
Example #12
Source File: AnimationDrawable.java    From TerraLegion with MIT License 5 votes vote down vote up
private static void addMiddleReversed(Array<TextureRegion> frames, boolean keepFirst) {
    if (frames.size < 3) {
        return;
    }
    Array<TextureRegion> middleReversed = new Array<TextureRegion>(frames);
    if (!keepFirst) {
        middleReversed.removeIndex(0);
    }
    middleReversed.removeIndex(middleReversed.size - 1);
    middleReversed.reverse();
    frames.addAll(middleReversed);
}
 
Example #13
Source File: GameEntity.java    From Entitas-Java with MIT License 5 votes vote down vote up
public GameEntity addTextureView(String name, TextureRegion texture,
		Body body) {
	TextureView component = (TextureView) recoverComponent(GameComponentsLookup.TextureView);
	if (component == null) {
		component = new TextureView(name, texture, body);
	} else {
		component.name = name;;
		component.texture = texture;;
		component.body = body;
	}
	addComponent(GameComponentsLookup.TextureView, component);
	return this;
}
 
Example #14
Source File: InventoryPanel.java    From riiablo with Apache License 2.0 5 votes vote down vote up
BodyPart(BodyLoc bodyLoc, TextureRegion background) {
  this.bodyLoc = bodyLoc;
  this.background = background;
  addListener(clickListener = new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
      Item cursor = Riiablo.cursor.getItem();
      if (cursor != null) {
        if (!ArrayUtils.contains(cursor.typeEntry.BodyLoc, bodyPart)) {
          Riiablo.audio.play(Riiablo.charData.classId.name().toLowerCase() + "_impossible_1", false);
          return;
        }

        Riiablo.audio.play(cursor.getDropSound(), true);
        if (item != null) {
          itemController.swapBodyItem(BodyPart.this.bodyLoc, false);
        } else {
          itemController.cursorToBody(BodyPart.this.bodyLoc, false);
        }
        item = cursor;
      } else {
        item = null;
        itemController.bodyToCursor(BodyPart.this.bodyLoc, false);
      }
    }
  });
  xOffs = yOffs = 0;
  xOffsAlt = Integer.MIN_VALUE;
  yOffsAlt = Integer.MIN_VALUE;
}
 
Example #15
Source File: SpriteSheet.java    From TerraLegion with MIT License 5 votes vote down vote up
public void load(Texture texture, int spriteWidth, int spriteHeight, int gapWidth, int gapHeight) {
    dispose();
    
    this.texture = texture;
    this.spriteWidth = spriteWidth;
    this.spriteHeight = spriteHeight;
    this.gapWidth = gapWidth;
    this.gapHeight = gapHeight;
    
    final int width = texture.getWidth();
    final int height = texture.getHeight();
    rowCount = ((width - spriteWidth) / (spriteWidth + gapWidth)) + 1;
    columnCount = ((height - spriteHeight) / (spriteHeight + gapHeight)) + 1;
    if ((height - spriteHeight) % (spriteHeight + gapHeight) != 0) {
        columnCount++;
    }
    
    sprites = new TextureRegion[columnCount][rowCount];
    mirrored = new TextureRegion[columnCount][rowCount];
    for (int column = 0; column < columnCount; column++) {
        for (int row = 0; row < rowCount; row++) {
            sprites[column][row] = extractSprite(row, column);
            TextureRegion mirroredSprite = new TextureRegion(sprites[column][row]);
            mirroredSprite.flip(true, false);
            mirrored[column][row] = mirroredSprite;
        }
    }
}
 
Example #16
Source File: SceneList.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public TextureRegion getBgIcon(String atlas, String region) {

		// check here for dispose instead in project loading because the opengl
		// context lost in new project thread
		if (disposeBgCache) {
			dispose();
			disposeBgCache = false;
		}

		String s = atlas + "#" + region;
		TextureRegion icon = bgIconCache.get(s);

		if (icon == null) {
			Batch batch = getStage().getBatch();
			batch.end();

			try {
				icon = createBgIcon(atlas, region);
			} catch (Exception e) {
				EditorLogger.error("Error creating Background icon: " + atlas + "." + region);
			}

			if (icon == null) {
				EditorLogger.error("Error creating Background icon: " + atlas + "." + region);
				icon = Ctx.assetManager.getIcon("ic_no_scene");
			}

			bgIconCache.put(s, icon);

			batch.begin();

		}

		return icon;
	}
 
Example #17
Source File: SkinNumber.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public SkinNumber(TextureRegion[][] image, TextureRegion[][] mimage, int timer, int cycle, int keta, int zeropadding, int space, int id) {
	this.image = new SkinSourceImage(image, timer, cycle) ;
	this.mimage = mimage != null ? new SkinSourceImage(mimage, timer, cycle) : null;
	this.setKeta(keta);
	this.zeropadding = zeropadding;
	this.space = space;
	ref = IntegerPropertyFactory.getIntegerProperty(id);
}
 
Example #18
Source File: HelpScreen3.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
public HelpScreen3 (SuperJumper game) {
	this.game = game;

	guiCam = new OrthographicCamera(320, 480);
	guiCam.position.set(320 / 2, 480 / 2, 0);
	nextBounds = new Rectangle(320 - 64, 0, 64, 64);
	touchPoint = new Vector3();
	helpImage = Assets.loadTexture("data/help3.png");
	helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}
 
Example #19
Source File: AnimationManager.java    From Unlucky with MIT License 5 votes vote down vote up
/**
 * Sets up for single animations
 *
 * @param sprites 2d array of sprites so that different sized animations can be used
 * @param numFrames the amount of frames in the single animation
 * @param delay
 */
public AnimationManager(TextureRegion[][] sprites, int numFrames, int index, float delay) {
    TextureRegion[] frames = new TextureRegion[numFrames];

    width = sprites[index][0].getRegionWidth();
    height = sprites[index][0].getRegionHeight();

    for (int i = 0; i < numFrames; i++) {
        frames[i] = sprites[index][i];
    }

    currentAnimation = new CustomAnimation(delay, frames);
}
 
Example #20
Source File: Box2dLightTest.java    From box2dlights with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	MathUtils.random.setSeed(Long.MIN_VALUE);

	camera = new OrthographicCamera(viewportWidth, viewportHeight);
	camera.position.set(0, viewportHeight / 2f, 0);
	camera.update();
	
	batch = new SpriteBatch();
	font = new BitmapFont();
	font.setColor(Color.RED);
	
	textureRegion = new TextureRegion(new Texture(
			Gdx.files.internal("data/marble.png")));
	bg = new Texture(Gdx.files.internal("data/bg.png"));

	createPhysicsWorld();
	Gdx.input.setInputProcessor(this);

	normalProjection.setToOrtho2D(
			0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

	/** BOX2D LIGHT STUFF BEGIN */
	RayHandler.setGammaCorrection(true);
	RayHandler.useDiffuseLight(true);
	
	rayHandler = new RayHandler(world);
	rayHandler.setAmbientLight(0f, 0f, 0f, 0.5f);
	rayHandler.setBlurNum(3);

	initPointLights();
	/** BOX2D LIGHT STUFF END */

}
 
Example #21
Source File: GigaGal.java    From ud406 with MIT License 5 votes vote down vote up
public void render(SpriteBatch batch) {
    TextureRegion region = Assets.instance.gigaGalAssets.standingRight;


    // TODO: Select the correct sprite based on facing, jumpState, and walkState
    if (facing == Facing.RIGHT && jumpState != JumpState.GROUNDED) {
        region = Assets.instance.gigaGalAssets.jumpingRight;
    } else if (facing == Facing.RIGHT) {
        region = Assets.instance.gigaGalAssets.standingRight;
    }  else if (facing == Facing.LEFT && jumpState != JumpState.GROUNDED) {
        region = Assets.instance.gigaGalAssets.jumpingLeft;
    } else if (facing == Facing.LEFT) {
        region = Assets.instance.gigaGalAssets.standingLeft;
    }

    batch.draw(
            region.getTexture(),
            position.x - Constants.GIGAGAL_EYE_POSITION.x,
            position.y - Constants.GIGAGAL_EYE_POSITION.y,
            0,
            0,
            region.getRegionWidth(),
            region.getRegionHeight(),
            1,
            1,
            0,
            region.getRegionX(),
            region.getRegionY(),
            region.getRegionWidth(),
            region.getRegionHeight(),
            false,
            false);
}
 
Example #22
Source File: DebugAnimationEffect.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
@Override
    public void render(Canvas canvas, Camera camera, float a) {
            
        int rx = (int)(pos.x);
        int ry = (int)(pos.y);
        
        float alpha = 1.0f;
        if(!this.persist) {
             alpha = (float)this.fade.getCurrentValue() / 255.0f;
        }
        
        float priorAlpha = canvas.getCompositeAlpha();
        canvas.setCompositeAlpha(alpha);
        
        TextureRegion region = anim.getCurrentImage();
        sprite.setRegion(region);
                
        if(offsetX != 0 || offsetY != 0) {
            //sprite.setSize(16, 16);
            sprite.setPosition(rx-offsetX, ry-offsetY);
            //sprite.setPosition(rx+22, ry-43);
            sprite.setOrigin(offsetX, offsetY);
        }
        else {
            int w = region.getRegionWidth() / 2;
            int h = region.getRegionHeight() / 2;
            
            sprite.setPosition(rx-w, ry-h);
        }
        sprite.setRotation(this.rotation-90);
        
//        sprite.setColor(1, 1, 1, alpha);
        canvas.drawSprite(sprite);
        canvas.drawRect( (int)sprite.getX(), (int)sprite.getY(), sprite.getRegionWidth(), sprite.getRegionHeight(), 0xff00aa00);
        canvas.setCompositeAlpha(priorAlpha);
    }
 
Example #23
Source File: EditorAssetManager.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public TextureRegion getIcon(String name) {
	TextureAtlas a = get(ICON_ATLAS, TextureAtlas.class);

	AtlasRegion region = a.findRegion(name);

	if (region == null) {
		EditorLogger.error("Region " + name + " not found in icon atlas ");
	}

	return region;
}
 
Example #24
Source File: AbstractServerSetupScreen.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
protected ImagePanel setupImagePanel(Vector2f pos, TextureRegion image) {
    ImagePanel panel = new ImagePanel(image);
    panel.setBounds(new Rectangle((int)pos.x, (int)pos.y, image.getRegionWidth(), image.getRegionHeight()));
    panel.setBackgroundColor(0x00000000);
    panel.setForegroundColor(0x00000000);
    
    this.optionsPanel.addWidget(panel);
    this.panelView.addElement(new ImagePanelView(panel));
    
    return panel;
}
 
Example #25
Source File: SkinSourceImage.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public void dispose() {
	if (image != null) {
		for (TextureRegion[] trs : image) {
			if (trs != null) {
				for (TextureRegion tr : trs) {
					tr.getTexture().dispose();
				}
			}
		}
		image = null;
	}
}
 
Example #26
Source File: DebugStatistics.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
private void init (int width, int height, float updateHz) {
	// assert (width < 256 && height < 256);

	final float oneOnUpdHz = 1f / updateHz;

	PanelWidth = width;
	PanelHeight = height;
	intervalNs = (long)(1000000000L * oneOnUpdHz);

	pixels = new Pixmap(PanelWidth, PanelHeight, Format.RGBA8888);
	texture = new Texture(width, height, Format.RGBA8888);
	texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
	region = new TextureRegion(texture, 0, 0, pixels.getWidth(), pixels.getHeight());

	// create data
	dataRenderTime = new float[PanelWidth];
	dataFps = new float[PanelWidth];
	dataPhysicsTime = new float[PanelWidth];
	dataTimeAliasing = new float[PanelWidth];

	// precompute constants
	ratio_rtime = ((float)PanelHeight / 2f) * Config.Physics.TimestepHz;
	ratio_ptime = ((float)PanelHeight / 2f) * Config.Physics.TimestepHz;
	ratio_fps = ((float)PanelHeight / 2f) * oneOnUpdHz;

	reset();
}
 
Example #27
Source File: ImageHelper.java    From gdx-fireapp with Apache License 2.0 5 votes vote down vote up
/**
 * Transforms byte[] to Texture Region.
 * <p>
 * If you are going to call this method inside firebase callback remember to wrap it<p>
 * into {@code Gdx.app.postRunnable(Runnable)}.
 * The texture will be changed so that it has sides with length of power of 2.
 *
 * @param bytes Byte array with image description
 * @return Texture region representation of given byte array
 */
public TextureRegion createTextureFromBytes(byte[] bytes) {
    Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
    final int orgWidth = pixmap.getWidth();
    final int orgHeight = pixmap.getHeight();
    int width = MathUtils.nextPowerOfTwo(orgWidth);
    int height = MathUtils.nextPowerOfTwo(orgHeight);
    final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat());
    potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
    pixmap.dispose();
    TextureRegion region = new TextureRegion(new Texture(potPixmap), 0, 0, orgWidth, orgHeight);
    potPixmap.dispose();
    return region;
}
 
Example #28
Source File: FallingObjectFactory.java    From FruitCatcher with Apache License 2.0 5 votes vote down vote up
public FallingObject getStar() {
    TextureRegion [] textureRegions = new TextureRegion[2];
    textureRegions[0] = imageProvider.getStarFrame(2);
    textureRegions[1] = imageProvider.getStarFrame(3);
    
    FallingObjectState model = new FallingObjectState();
    model.setType(FallingObjectType.BonusObject);
    return new FallingObject(imageProvider, textureRegions, 
                             model);
}
 
Example #29
Source File: SkinNumber.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public SkinNumber(TextureRegion[][] image, TextureRegion[][] mimage, int timer, int cycle, int keta, int zeropadding, int space, IntegerProperty ref) {
	this.image = new SkinSourceImage(image, timer, cycle) ;
	this.mimage = mimage != null ? new SkinSourceImage(mimage, timer, cycle) : null;
	this.setKeta(keta);
	this.zeropadding = zeropadding;
	this.space = space;
	this.ref = ref;
}
 
Example #30
Source File: GdxCanvas.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void drawImage(TextureRegion image, int x, int y, Integer color) {
    
    Color c= Color.WHITE;
    if (color != null) c = setTempColor(color);
    
    if(!isBegun) batch.begin(); 
    batch.setColor(c);        
    batch.draw(image, x, y);                
    if(!isBegun) batch.end();
}