This is driving me a little crazy. We use libGDX, working on making a simple side scroller for fun. I've got it switching from screens alright, loading from my main menu into my level one class, which implements screen.
public class levelOne implements Screen
Don't know if that effects this. When I try to initialize my sprite, my editor (AIDE) highlights it. Gives me an error saying that there is no access to the variable, as it does when you declare something but don't use it.
Texture faceTexture = new Texture(Gdx.files.internal("faceSprite.png")); faceGuy = new TextureRegion(faceTexture, 50, 50, 95, 95); Sprite player = new Sprite(faceGuy);
I do actually call up the sprite in
batch.begin(); // Background batch.draw(backGround,0,0,2900,800); // Player player.draw(batch); // Enemies batch.draw(faceGuy, baddieOnePosition.x, baddieOnePosition.y, 150, 150); batch.end();
It doesn't generate an error there, but trying to run it generates a crash. I can do a
batch.draw of the texture, but every attempt at doing it as a sprite fails. I have it being initialized in
show(), thought maybe making a new method to do so would help, but had the same result. The only way I've managed to make it work was to initialize it in
render(), but that not only resets the sprites position multiple times a second, but I expect is also a memory hog. Help!