java - Recipe App , best way to make selection for recipes? -
so designing app libgdx , kind of simple app anyway. recipe guide app. best way render selection screen recipes , thinking create table , display recipes , make clickable / touchable. don't know first way start doing in libgdx or if theirs better alternative.
ok tried make work getting error , know error means having difficult time finding null;
more eyes better one. err two.
this class recipescreen
private textureatlas atlas; private sprite sprite; private orthographiccamera camera; private assetmanager assets; private spritebatch batch; int[] blockmenu = new int[100]; public recipescreen(){ } public void create(){ camera = new orthographiccamera(720,1280); assets = new assetmanager(); if (gdx.app.gettype() == applicationtype.android){ assets.load("data/akemix.pack", textureatlas.class); assets.finishloading(); } else { assets.load("bin/data/bakemix.pack", textureatlas.class); assets.finishloading(); } if (gdx.app.gettype() == applicationtype.android){ atlas = assets.get("bin/data/bakemix.pack"); } else { atlas = assets.get("bin/data/bakemix.pack"); } sprite = new sprite(atlas.findregion("blockbacksel")); } public void renderblockmenu(){ //batch.setprojectionmatrix(camera.combined); batch.begin(); sprite.draw(batch); batch.end(); } public void dispose(){ assets.dispose(); batch.dispose(); }
}
this class start screen
public startscreen(){ } spritebatch batch; texture textbckg; bitmapfont font; inputmultiplexer ui; boolean leftpressed = false; boolean screentouched = false; debug debug = new debug(); recipescreen rscreen = new recipescreen(); screenstate sstate = new screenstate(); public void create(){ batch = new spritebatch(); font = new bitmapfont(); ui = new inputmultiplexer(); ui.addprocessor(new myinputprocessor()); sstate.setscreenstate(0); //set start gdx.input.setinputprocessor(ui); if (gdx.app.gettype() == applicationtype.android){ textbckg = new texture(gdx.files.internal("data/backgroundmix.png")); } else { textbckg = new texture(gdx.files.internal("bin/data/backgroundmix.png")); } if (gdx.app.gettype() == applicationtype.android){ font = new bitmapfont(gdx.files.internal("data/mixbig.fnt"),gdx.files.internal("data/mixbig.png"),false); } else { font = new bitmapfont(gdx.files.internal("bin/data/mixbig.fnt"),gdx.files.internal("bin/data/mixbig.png"),false); } } public void render(){ batch.begin(); if (sstate.getscreenstate() == 0){ batch.draw(textbckg,0,0,1280,720); font.setcolor(1.0f,1.0f,1.0f,1.0f); font.draw(batch, " baker mix ", 180, 400); font.draw(batch, " touch start! ", 180, 350); isstarthit(); } else if (sstate.getscreenstate() == 1){ batch.draw(textbckg,0,0,32,32); rscreen.renderblockmenu(); } //debug.displaydebugcoords(); batch.end(); } public void dispose(){ batch.dispose(); textbckg.dispose(); debug.dispose(); font.dispose(); } public void isstarthit(){ if (gdx.app.gettype() == applicationtype.android){ if (screentouched = gdx.input.istouched()){ font.draw(batch, "button pressed!", 180, 300); sstate.setscreenstate(1); } } else { if (leftpressed = gdx.input.isbuttonpressed(input.buttons.left)){ rscreen.create(); rscreen.renderblockmenu(); sstate.setscreenstate(1); } } }
}
Comments
Post a Comment