so i tried to re-make everything without using delta, and the result still the same :clue:
this is the new class (am not using the Screen class anymore, the other are the same ) :
and you can download the Jar file from here
package com.me.mygdxgame;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.me.mygdxgame.entities.Player;
public class MyGdxGame implements ApplicationListener {
private SpriteBatch batch;
private boolean leftPressed, rightPressed, upPressed, downPressed;
private Texture heroTexture;
private Sprite heroSprite;
private float xSpeed, ySpeed, xDirection, yDirection;
private Player player;
@Override
public void create() {
player = new Player(100, 100, 16, 16);
heroTexture = new Texture("data/heroRight.png");
heroTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
heroSprite = new Sprite(heroTexture);
batch = new SpriteBatch();
xSpeed = 10;
ySpeed = 10;
}
@Override
public void dispose() {
}
@Override
public void render() {
Gdx.gl.glClearColor(0.2f, 0.2f, 0.3f, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
control();
player.update(xDirection, yDirection);
heroSprite.setColor(1, 1, 1, 1);
heroSprite.setX(player.getX());
heroSprite.setY(player.getY());
batch.begin();
heroSprite.draw(batch);
batch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
private void control() {
leftPressed = Gdx.input.isKeyPressed(Keys.DPAD_LEFT);
rightPressed = Gdx.input.isKeyPressed(Keys.DPAD_RIGHT);
upPressed = Gdx.input.isKeyPressed(Keys.DPAD_UP);
downPressed = Gdx.input.isKeyPressed(Keys.DPAD_DOWN);
if (rightPressed) {
xDirection = xSpeed;
} else if (leftPressed) {
xDirection = -xSpeed;
} else {
xDirection = 0;
}
if (upPressed) {
yDirection = ySpeed;
} else if (downPressed) {
yDirection = -ySpeed;
} else {
yDirection = 0;
}
}
}
thank you