I have been having a problem with the rendering in my screens.
Basically I have an overall class that extends Game and I have created a few other classes for the various pages for my game such as the Main Menu, the actual game etc. When I call setScreen(screen) on one of these classes the rendering loop of that screen is called, but I cant seem to draw anything.
What I have done is that I created the orthographic camera and spritebatch in the overall game class and passed it to the screens through their constructor method. However, I don't seem to be able to draw anything. The screen still clears the background.
Sorry I don't have my source code at the moment but here is roughly what it looks like:
This is my overall game class:
public class MyGdxGame extends Game {
public OrthographicCamera camera;
public SpriteBatch batch;
public ResourceManager Rm;
public StartScreen MainMenu;
public GameScreen CellTD;
public InstructionsScreen Instructions;
public PauseScreen Pause;
#Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
Rm = new ResourceManager();
camera = new OrthographicCamera(1.0f, h/w);
batch = new SpriteBatch();
Rm.LoadTexture("Cell.png");
MainMenu = new StartScreen(camera, batch, Rm, this);
CellTD = new GameScreen(camera, batch, Rm, this);
Instructions = new InstructionsScreen(camera, batch, Rm, this);
Pause = new PauseScreen(camera, batch, Rm, this);
setScreen(MainMenu);
}
#Override
public void dispose() {
}
#Override
public void resize(int width, int height) {
}
#Override
public void pause() {
}
#Override
public void resume() {
}
}
This is one of my screen classes:
public class StartScreen implements Screen{
private OrthographicCamera camera;
private SpriteBatch batch;
private ResourceManager Rm;
private int SCREEN_W, SCREEN_H;
public MyGdxGame Parent;
private Label Title;
private Sprite s;
StartScreen(OrthographicCamera c, SpriteBatch b, ResourceManager r, MyGdxGame g)
{
camera = c;
batch = b;
Rm = r;
SCREEN_W = Gdx.graphics.getWidth();
SCREEN_H = Gdx.graphics.getHeight();
Parent = g;
camera.setToOrtho(false,1.0f,SCREEN_H/SCREEN_W);
camera.update();
Title = new Label("Cell TD",new Label.LabelStyle(new BitmapFont(Gdx.files.internal("data/CellTDFont.fnt"),false) ,new Color(1.0f,1.0f,1.0f,1.0f)));
Title.setText("Cell TD");
Title.setSize(1.0f, SCREEN_H/SCREEN_W);
Title.setOrigin(Title.getWidth()/2, Title.getHeight()/2);
Title.setPosition(0, 0);
s = new Sprite(Rm.GetTexture("Cell.png"));
s.setSize(1.0f, SCREEN_H/SCREEN_W);
s.setOrigin(s.getWidth()/2, s.getHeight()/2);
s.setPosition(-0.5f, -SCREEN_H/SCREEN_W/2);
}
#Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0.9f, 0.9f, 0);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(camera.combined);
batch.begin();
//Title.draw(batch,1);
s.draw(batch);
batch.end();
}
#Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
#Override
public void show() {
// TODO Auto-generated method stub
}
#Override
public void hide() {
// TODO Auto-generated method stub
}
#Override
public void pause() {
// TODO Auto-generated method stub
}
#Override
public void resume() {
// TODO Auto-generated method stub
}
#Override
public void dispose() {
// TODO Auto-generated method stub
}
}
Its an easy bug.
Your camera is not correct i guess.
c = new OrthographicCamera(1.0f,h/w);
this means that the camera is 1px width and h/w height... and your sprite is like 100x200 for example. So the only thing you will see is around 1px of the sprite.
Do change the constructor of it to something liket this:
float w = Gdx.graphics.getWidth(); //the width of the window
float h = Gdx.graphics.getHeight();//the height of the window
camera = new OrthographicCamera(w, h);
Dont forget to resize the camera inside of the resize.
maybe take a look at the new libgdx wiki here:
Orthographic camera
Spritebatch, textureregions, and sprite
Related
I successfully implemented a gifdecoder in my project and wrote a gifloader for it to use it with the assetmanager. I am able to load the gif in the assetmanager and I am also able to draw it. But everytime I try to load gifs in my assetmanager with manager.update() I can not draw animations anymore, only non animated textures.
Here is my code I hope somebody has an idea
public class Load implements Screen {
private SpriteBatch batch;
private Animation<TextureRegion> loadingAnimation;
private TextureAtlas atlasLoading = new TextureAtlas(Gdx.files.internal("atlas/loadingAnimation.atlas"));
float stateTime;
MainExecute lr;
public FileHandleResolver resolver = new InternalFileHandleResolver();
public AssetManager manager = new AssetManager();
private final Animation animation = GifDecoder.loadGIFAnimation(Animation.PlayMode.NORMAL, Gdx.files.internal("data/loading.gif").read());
public Load(MainExecute lr){
this.lr = lr;
}
public Texture Bg1;
#Override
public void show() {
Bg1 = new Texture(Gdx.files.internal("bggamescreen.png"));
batch = new SpriteBatch();
manager.setLoader(GIF.class,new Gifloader(resolver));
manager.load("data/BackgroundAnim.gif",GIF.class);
stateTime = 0f;
}
#Override
public void render(float delta) {
if (manager.update())
{
lr.setScreen(new MainMenu(lr));
}
stateTime += delta;
// loadingAnimation = new Animation<TextureRegion>(0.5f, atlasLoading.findRegions("loading"),Animation.PlayMode.LOOP);
TextureRegion currentFrame = (TextureRegion) animation.getKeyFrame(stateTime, true);
batch.begin();
batch.draw(Bg1,0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
batch.draw(currentFrame, 0, 0, 200, 200);
batch.end();
}
#Override
public void resize(int width, int height) {
}
#Override
public void pause() {
}
#Override
public void resume() {
}
#Override
public void hide() {
}
#Override
public void dispose() {
}
}
Strange code, you are drawing animation before it finish loading. You need to waiting to load your animation, try smth like this.
if (manager.update())
{
loadingAnimation = new Animation<TextureRegion>(0.5f, atlasLoading.findRegions("loading"),Animation.PlayMode.LOOP);
TextureRegion currentFrame = (TextureRegion) animation.getKeyFrame(stateTime, true);
lr.setScreen(new MainMenu(lr));
}
Trying to create a simple loading Screen. The below code prints the correct progress, so I know that part works. But the rectangle is not being drawn. Not sure what is wrong.
Full LoadingScreen:
public class LoadingScreen implements Screen {
private static final float PROGRESS_BAR_WIDTH = MyGdxGame.WIDTH / 2f;
private static final float PROGRESS_BAR_HEIGHT = 50f;
GdxAssetManager assetManager;
Stage stage;
//Table mainTable;
private ShapeRenderer shapeRenderer;
private MyGdxGame game;
public LoadingScreen(MyGdxGame game){
this.game = game;
assetManager = game.getAssetManager();
shapeRenderer = new ShapeRenderer();
stage = new Stage(new StretchViewport(MyGdxGame.WIDTH, MyGdxGame.HEIGHT));
}
#Override
public void show() {
assetManager.loadGeneral();
}
#Override
public void render(float delta) {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderProgressBar();
if (assetManager.getManager().update()) {
game.setScreen(new LoginScreen(game));
}
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
private void renderProgressBar() {
float progress = assetManager.getManager().getProgress();
System.out.println(PROGRESS_BAR_WIDTH * progress);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(Color.RED);
shapeRenderer.rect(
(MyGdxGame.WIDTH - PROGRESS_BAR_WIDTH) / 2f,
(MyGdxGame.HEIGHT - PROGRESS_BAR_HEIGHT) / 2f,
PROGRESS_BAR_WIDTH * progress,
PROGRESS_BAR_HEIGHT
);
shapeRenderer.end();
}
#Override
public void resize(int width, int height) {
stage.getViewport().update(width, height);
}
#Override
public void pause() {
}
#Override
public void resume() {
}
#Override
public void hide() {
dispose();
}
#Override
public void dispose() {
stage.dispose();
shapeRenderer.dispose();
}
}
I guess methods of interest are render and renderProgressBar. Like I said, all I get is a white background until the loading is finished, but the print inside renderProgressBar prints the correct values.
Set projectionMatrix of ShapeRenderer using stage camera.
shapeRenderer.setProjectionMatrix(stage.getCamera().combined);
image of problem http://imgur.com/ZNpHiiu so I succesfully rendered a background for my game , now i tried to render some sprites on top of it and screen gets all messed up big Blue L.
code main
public class WizardGame extends Game {
public static final String TITLE = "Are you a bad enough wizard to save the princess?!", VERISION = "0.0.0.0.PREALPHA";
PlayTest pt = new PlayTest();
private FPSLogger fps;
public void create() {
Gdx.gl20.glClearColor(0, 0, 0, 1);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
fps = new FPSLogger();
fps.log();
pt.create();
}
public void dispose() {
super.dispose();
}
public void render() {
super.render();
pt.render();
}
public void resize(int width, int height) {
super.resize(width, height);
}
public void pause() {
super.pause();
}
public void resume() {
super.resume();
}
}
playtest code
public class PlayTest implements Screen {
private TextureAtlas atlas;
private AtlasRegion floor;
private SpriteBatch batch;
private OrthographicCamera camera;
private Sprite background;
private BitmapFont font;
private String fps;
Blocks block = new Blocks();
public void render() {
Gdx.gl20.glClearColor(0, 0, 05, 1);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
background.setBounds(0, 0, 720, 1280);
background.draw(batch);
block.renderBlocks();
batch.end();
}
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
public void show() {
}
public void hide() {
}
public void pause() {
}
public void resume() {
}
public void dispose() {
atlas.dispose();
batch.dispose();
}
public void create() {
atlas = new TextureAtlas(Gdx.files.internal("data/wizardpack.pack"));
floor = atlas.findRegion("Backfloor");
background = new Sprite(floor);
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("data/magicdebug48.fnt"));
block.create();
}
#Override
public void render(float delta) {
// TODO Auto-generated method stub
}
}
block code
public class Blocks extends Game {
private TextureAtlas atlas;
private SpriteBatch batch;
private AtlasRegion sword,shield,staff,fireball,iceball;
private Sprite sprSword,sprShield,sprStaff,sprFireball,sprIceball;
#Override
public void create() {
atlas = new TextureAtlas(Gdx.files.internal("data/wizardpack.pack"));
batch = new SpriteBatch();
sword = atlas.findRegion("Sword");
shield = atlas.findRegion("Shield");
staff = atlas.findRegion("Staff");
fireball = atlas.findRegion("flame");
iceball = atlas.findRegion("icespell");
sprSword = new Sprite(sword);
sprShield = new Sprite(shield);
sprStaff = new Sprite(staff);
sprFireball = new Sprite(fireball);
sprIceball = new Sprite(iceball);
}
public void renderBlocks(){
Gdx.gl20.glClearColor(0, 0, 05, 1);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(sword, 0, 0, 0, 0, 32, 32, 1, 1, 0);
//sprShield.setBounds(15, 15, 32, 32);
// sprShield.draw(batch);
batch.end();
}
public void dispose(){
atlas.dispose();
batch.dispose();
}
}
I fixed it :D the call to renderBlocks has to be after the end of batch.
I'm fairly new to Game development and to Libgdx as well. I'have looked around other similar topics in the forum but often I'm confused trying to understanding their content, therefore I decided to write down my problem here.
My problem is all about creating a minimap in the left bottom corner of the game screen showing the entire world with actors. I'd like to use the scene2d concept as much as possible.
For now I'm concentrating on the desktop version of the game.
I have a windows screen ... saying width = 800, height = 600
The top class of the game, MyOp0Game, is like this:
public class MyOp0Game extends Game {
MyScreen0 my_screen_0;
#Override
public void create() {
// allocate screen
my_screen_0 = new MyScreen0(this);
// set current screen
setScreen(my_screen_0);
}
#Override
public void render() {
super.render();
}
}
The MyScreen0 class is like this:
public class MyScreen0 implements Screen{
protected final Stage stage0;
protected final MyOp0Game game;
protected final MyActor0 actor0;
protected final MyActor0 actor1;
public MyScreen0(MyOp0Game game) {
// link screen to game
this.game = game;
// allocate stage; viewport size maps screen size
this.stage0 = new Stage( Gdx.graphics.getWidth(),Gdx.graphics.getHeight(), true );
// allocate actor0 and add to stage
this.actor0 = new MyActor0();
this.actor0.setPosition(0, 0);
this.stage0.addActor(this.actor0);
// allocate actor1 and add to stage, actor1 is placed next to actor0
this.actor1 = new MyActor0();
this.actor1.setPosition(1000, 0);
this.stage0.addActor(this.actor1);
}
#Override
public void render(float delta) {
// the following code clears the screen with the given RGB color (green)
Gdx.gl.glClearColor( 0f, 1f, 0f, 1f );
Gdx.gl.glClear( GL20.GL_COLOR_BUFFER_BIT );
// translate stage camera to go from actor0 to actor1
//this.stage0.getCamera().translate(1, 0, 0);
// draw stage -> draw actors
this.stage0.draw();
}
#Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
#Override
public void show() {
// not required as no abstract screen for now
//super.show();
}
#Override
public void hide() {
// TODO Auto-generated method stub
}
#Override
public void pause() {
// TODO Auto-generated method stub
}
#Override
public void resume() {
// TODO Auto-generated method stub
}
#Override
public void dispose() {
this.stage0.dispose();
}
}
Finally the MyActor0 class is like this :
public class MyActor0 extends Actor {
SpriteBatch batch;
Texture texture;
public MyActor0() {
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/libgdx.png"));
}
public void draw(SpriteBatch batch, float alpha){
batch.draw(texture,this.getX(),this.getY());
}
}
The stage viewport is of the same size as the window screen.
The actor texture is smaller than the viewport and therefore the first actor is visible and the second actor is not visible as it is next to the viewport.
I would like to insert in the bottom left a minimap showing the two actors (or equivalent markers).
I've tried several options but it never works, using two cameras and switching between them, two stages?
I think one fundamental question I have is : does the viewport always fills the windows screen?
I have seen your comment but i could not find a Minimap Actor in the libgdx documentations. But i found this link, which may help you out: Minimap. Tell me if this works (:
here is the first prototype of the minimap, it will be enough for the first step of the game dev.
public class Main {
public static void main(String[] args) {
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "my-op0-game";
cfg.useGL20 = false;
cfg.width = MyOp0Game.MY_APP_WINDOW_WIDTH;
cfg.height = MyOp0Game.MY_APP_WINDOW_HEIGHT;
new LwjglApplication(new MyOp0Game(), cfg);
}
}
public class MyOp0Game extends Game {
public static int MY_APP_WINDOW_WIDTH = 512;
public static int MY_APP_WINDOW_HEIGHT = 512;
public static int MY_WORLD_WIDTH = 2048;
public static int MY_WORLD_HEIGHT = 2048;
public static int MY_MINIMAP_WIDTH = 256;
public static int MY_MINIMAP_HEIGHT = 256;
public static int MY_MINIMAP_SCALE_FACTOR = MY_WORLD_WIDTH / MY_MINIMAP_WIDTH;
public static int MY_ORIGINAL_CAMERA_POSITION_X = MY_APP_WINDOW_WIDTH/2;
public static int MY_ORIGINAL_CAMERA_POSITION_Y = MY_APP_WINDOW_HEIGHT/2;
public static final String LOG = "MyOp0Game";
MyScreen0 my_screen_0;
#Override
public void create() {
// allocate screen
my_screen_0 = new MyScreen0(this);
// set current screen
setScreen(my_screen_0);
}
#Override
public void render() {
super.render();
}
}
public class MyScreen0 implements Screen{
protected final Stage stage0;
protected final MyOp0Game game;
protected final MyActor0 actor0_0;
protected final MyActor0 actor0_1;
protected final MyActor1 actor1_0;
public MyScreen0(MyOp0Game game) {
// link screen to game
this.game = game;
// allocate stage; viewport size maps game window size
this.stage0 = new Stage( Gdx.graphics.getWidth(),Gdx.graphics.getHeight(), true );
// allocate actor0_0 and add to stage
this.actor0_0 = new MyActor0();
this.actor0_0.setPosition(0, 0);
this.stage0.addActor(this.actor0_0);
// allocate actor0_1 and add to stage, actor1 is placed next to actor0
this.actor0_1 = new MyActor0();
this.actor0_1.setPosition(512, 256);
this.stage0.addActor(this.actor0_1);
// allocate actor1_0 and add to stage
this.actor1_0 = new MyActor1();
this.actor1_0.setPosition(0, MyOp0Game.MY_APP_WINDOW_HEIGHT - MyOp0Game.MY_MINIMAP_HEIGHT);
this.stage0.addActor(this.actor1_0);
}
#Override
public void render(float delta) {
int lvTranslateX = 0;
int lvTranslateY = 0;
// the following code clears the screen with the given RGB color (green)
Gdx.gl.glClearColor( 0f, 1f, 0f, 1f );
Gdx.gl.glClear( GL20.GL_COLOR_BUFFER_BIT );
/* check if mouse pressed */
if (Gdx.input.isTouched())
{
//Gdx.app.log( MyOp0Game.LOG, " mouse X = "+ Gdx.input.getX() +
// " Camera.x = " + this.stage0.getCamera().position.x +
// " mouse Y = "+ (MyOp0Game.MY_APP_WINDOW_HEIGHT - Gdx.input.getY()) +
// " Camera.y = " + this.stage0.getCamera().position.y);
if (Gdx.input.getX() >= MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_X)
{
if (this.stage0.getCamera().position.x - MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_X < MyOp0Game.MY_WORLD_WIDTH - MyOp0Game.MY_APP_WINDOW_WIDTH)
lvTranslateX = 3;
}
else if (Gdx.input.getX() < MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_X)
{
if (this.stage0.getCamera().position.x - MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_X > 0)
lvTranslateX = -3;
}
if (MyOp0Game.MY_APP_WINDOW_HEIGHT - Gdx.input.getY() >= MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_Y)
{
if (this.stage0.getCamera().position.y - MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_Y < MyOp0Game.MY_WORLD_HEIGHT - MyOp0Game.MY_APP_WINDOW_HEIGHT)
lvTranslateY = 3;
}
else if (MyOp0Game.MY_APP_WINDOW_HEIGHT - Gdx.input.getY() < MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_Y)
{
if (this.stage0.getCamera().position.y - MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_Y > 0)
lvTranslateY = -3;
}
if (lvTranslateX != 0 || lvTranslateY != 0)
{
// translate stage camera to go from actor0 to actor1
this.stage0.getCamera().translate(lvTranslateX, lvTranslateY, 0);
// update actor1_0 (minimap) location to move with camera
this.actor1_0.translate(lvTranslateX,lvTranslateY);
}
};
// draw stage -> draw actors
this.stage0.draw();
}
#Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
#Override
public void show() {
// not required as no abstract screen for now
//super.show();
}
#Override
public void hide() {
// TODO Auto-generated method stub
}
#Override
public void pause() {
// TODO Auto-generated method stub
}
#Override
public void resume() {
// TODO Auto-generated method stub
}
#Override
public void dispose() {
this.stage0.dispose();
}
}
public class MyActor0 extends Actor {
SpriteBatch batch;
public Texture texture;
public MyActor0() {
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/libgdx_256_256.png"));
}
public void draw(SpriteBatch batch, float alpha){
batch.draw(texture,this.getX(),this.getY());
}
}
public class MyActor1 extends Actor {
SpriteBatch batch;
Texture texture;
Texture blackMarkerTexture;
Texture yelloCameraMinimapTexture;
public MyActor1() {
this.batch = new SpriteBatch();
this.texture = new Texture(Gdx.files.internal("data/blueBg_256_256.png"));
this.blackMarkerTexture = new Texture(Gdx.files.internal("data/blackMarker_32_32.png"));
this.yelloCameraMinimapTexture = new Texture(Gdx.files.internal("data/yelloCameraMinimap_64_64.png"));
this.setName("minimap");
}
public void draw(SpriteBatch batch, float alpha){
// draw actor
batch.draw(texture,this.getX(),this.getY());
// draw game window in minimap
batch.draw( this.yelloCameraMinimapTexture,
this.getX() + (this.getStage().getCamera().position.x - MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_X)/MyOp0Game.MY_MINIMAP_SCALE_FACTOR,
this.getY() + (this.getStage().getCamera().position.y - MyOp0Game.MY_ORIGINAL_CAMERA_POSITION_Y)/MyOp0Game.MY_MINIMAP_SCALE_FACTOR);
// retrieve actors from stage
Array<Actor> lvActorArray = this.getStage().getActors();
for ( int lvIdx = 0; lvIdx < lvActorArray.size; lvIdx++ )
{
Actor lvActor = lvActorArray.get(lvIdx);
if (lvActor.getName() != "minimap")
{
batch.draw( this.blackMarkerTexture,
this.getX() + (lvActor.getX()/MyOp0Game.MY_MINIMAP_SCALE_FACTOR),
this.getY() + (lvActor.getY()/MyOp0Game.MY_MINIMAP_SCALE_FACTOR));
}
}
}
}
I am trying to override my Player class that extends Actor draw method but I am receiving an error saying
The method draw(SpriteBatch, float) of type Player must override or
implement a supertype method
Why can I not override the default draw method from the class Actor? Here is my code from the Player class.
public class Player extends Actor {
#Override
public void draw(SpriteBatch batch, float parentAlpha) {
Gdx.app.log(getName(), "Drawing player");
}
public Player() {
setName("mainPlayer");
playerBounds = new Rectangle(100, 100, 32, 32);
}
}
Here is my code from the class with the Stage that is being drawn.
public class Mainscreen implements Screen {
// Class TAG
private static final String TAG = "Main Screen";
// Screen Variable(s)
private Awakening g;
private SpriteBatch sprBatch;
private OrthographicCamera gameCamera;
private Player mainPlayer;
// Screen Stage(s)
private sMain sMain;
#Override
public void dispose() {
sprBatch.dispose();
sMain.dispose();
}
#Override
public void hide() {
g.inputController.removeProcessor(sMain);
dispose();
}
public Mainscreen(Awakening game){
g = game;
sMain = new sMain(g, g.configMgr.getWidth(), g.configMgr.getHeight(), true);
gameCamera = new OrthographicCamera();
gameCamera.setToOrtho(false, sMain.getWidth(), sMain.getHeight());
mainPlayer = new Player(g, gameCamera);
g.setPlayer(mainPlayer);
sprBatch = new SpriteBatch();
g.mapMgr.setMap(g, gameCamera, "TestMap", mainPlayer);
sMain.addActor(mainPlayer);
}
#Override
public void pause() {g.togglePause(true);g.debugOut(TAG, "pause()");}
#Override
public void render(float delta) {
if(!g.isPaused()){
sMain.act(delta);
Gdx.gl.glClearColor(.125f, .125f, .125f, 0);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gameCamera.update();
g.mapMgr.updateNPCS();
sprBatch.setProjectionMatrix(gameCamera.combined);
sprBatch.begin();
g.mapMgr.draw(gameCamera, new int[] {0,1});
sMain.draw(); // Draw player/NPCs
//g.getPlayer().draw(sprBatch, 0f);
g.mapMgr.drawCollisionRectangles(gameCamera);
sprBatch.end();
}
}
#Override
public void resize(int width, int height) {g.debugOut(TAG,"resize("+width+","+height+")");}
#Override
public void resume() {g.togglePause(false);g.debugOut(TAG, "resume()");}
#Override
public void show() {
g.debugOut(TAG, "show()");
g.inputController.addProcessor(sMain);
g.updateInput();
}
}
I am not sure what's going on but was pretty sure I could override draw before.
You must override it like this:
#Override
public void draw(Batch batch, float parentAlpha) {
Gdx.app.log(getName(), "Drawing player");
}
Change the SpriteBatch to Batch. Reference Actor#draw