Heya guys!
[quote][13:00:43] André Lopes: /**
* [15:57:52] Robin S: you would want to do something like this: if the
* camera viewport’s left border goes under 0, move back on the x axis same
* for the bottom border, if it goes under 0 move up then you need to check
* for the top and right borders use Camera#unproject(Vector3) to get the
* coordinates of the window borders and check if they are greater than the
* map
*/
[/quote]
The question is… how can i reach the value :
if ((camera.position.x/16) <= 25) {
25?
I know 16 is tile Width and tile height, so i dividided by that!
But what about when the level is different size? How can i reach that value?
public static void main(String[] args) {
// create the listener that will receive the application events
ApplicationListener listener = new MainView();
// define the window's title
String title = "Archer 0.5.3 Alpha Version";
// define the window's size
width = 800;
height = 600;
// whether to use OpenGL ES 2.0
boolean useOpenGLES2 = true;
// create the game
System.setProperty("user.name", "EnglishWords");
LwjglApplication lwjglApplication = new LwjglApplication(listener, title, width, height, useOpenGLES2);
Gdx.graphics.setVSync(true);
}
@Override
public void render(float delta) {
...
//Set Camera Position
camera.position.set(player.getX(), player.getY(), 0f);
camera.update();
//Dont show Black Spots (tmx = 69x449)
if ((camera.position.x/16) <= 25) {
camera.position.x = 25 * 16;//
System.out.println("camera.viewportWidth <= 0" + System.nanoTime());
camera.update();
}
if ((camera.position.y / 16) <= 19) {
camera.position.y = (19 * 16);
camera.update();
}
...
}