Hi! I'm just started studying this area, because of that I have some doubts about some mistakes that prevent my beginning and learning.
.O primeiro e o que eu dá uma certa dor de cabeça é o seguinteTento criar um botão usando a forma "Retângulo", mas quando tento o aplicativo iniciar em "run" (Shift+F10), ele não começa, e a mensagem a seguir é exibida:
"java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Rectangle;
at br.com.tpagames.BotaoNext.<init>(BotaoNext.java:22)
at br.com.tpagames.MainClass.create(MainClass.java:27)
button class code:
"package br.com.tpagames;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import java.awt.Rectangle;
public class BotaoNext {
public Rectangle botao_n;
public boolean pressionado = false;
private float fator_pressionado=1.1f;
private Texture textura_bn;
public BotaoNext(Texture textura_bn, int posx_btn, int posy_btn, int size_btn){
this.textura_bn =textura_bn;
botao_n = new Rectangle(posx_btn,posy_btn,size_btn,size_btn);
}
public void draw(SpriteBatch batch){
if (pressionado){
batch.draw(textura_bn, (float) (botao_n.x-((botao_n.getWidth())*(fator_pressionado-1))/2),
(float) (botao_n.y-((botao_n.getHeight())*(fator_pressionado-1))/2), (float) botao_n.getWidth(), (float) botao_n.getHeight());
}else {
batch.draw(textura_bn,botao_n.x,botao_n.y, (float) botao_n.getWidth(), (float) botao_n.getHeight()); //textura, posiçãoX, posiçãoY, larguraX, alturaY
}
}
public boolean verif(int x, int y){
if(botao_n.x<=x && botao_n.x + botao_n.width>=x &&
botao_n.y<=y && botao_n.y+botao_n.height>=y ){
pressionado=true;
}else {
pressionado=false;
}
return pressionado;
}
}
the main class code:
"package br.com.tpagames;
import static br.com.tpagames.Constantes.btn_size;
import static br.com.tpagames.Constantes.btn_x;
import static br.com.tpagames.Constantes.btn_y;
import static br.com.tpagames.Constantes.screeny;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class MainClass extends ApplicationAdapter {
private SpriteBatch batch;
private Menu1 menu1;
private Menu2 menu2;
private BotaoNext botão_next;
@Override
public void create () {
batch = new SpriteBatch();
menu1 = new Menu1();
menu2 = new Menu2();
botão_next = new BotaoNext(new Texture("Menu/botao_next.png"), btn_x,btn_y,btn_size);
}
//private int estado_atual = 0;
public int menu_atual = 0;
@Override
public void render () {
batch.begin();
draw();
input();
if (menu_atual>=2){
menu_atual = 0;
}
batch.end();
}
public void draw(){
if (menu_atual == 0){
botão_next.draw(batch);
menu1.draw(batch);
}
if (menu_atual == 1){
menu2.draw(batch);
}
}
public void input(){
if (Gdx.input.justTouched()){
int x = Gdx.input.getX();
int Y = screeny-Gdx.input.getY();
/*menu_atual = menu_atual+1;
*/
if (menu_atual>=2){
menu_atual = 0;
}
}
}
@Override
public void dispose () {
}
}"
constant class code:
"package br.com.tpagames;
import com.badlogic.gdx.Gdx;
public class Constantes {
public static int screenx = Gdx.graphics.getWidth();
public static int screeny = Gdx.graphics.getHeight();
public static int btn_size= (int)(0.4*screenx);
public static int btn_x = (int)(0.3f)*screenx;
public static int btn_y = (int)(screeny - btn_size/4);
}"
If anyone can help me, I would really appreciate it!!!