Hot answers tagged

9

It won't hurt performance. It might in fact be (very, very negligible) faster because you save the overhead of passing these objects to the game objects. The reason static classes are often frowned upon is that their static properties are global variables and globals cause all kinds of problems architecture-wise. For example, when you ever decide you might ...


3

If you're definitely only ever going to have one instance of these objects, and presumably you are, then this would be a better way to go. However, maybe a better solution would be to use the Singleton pattern, and (for example) create a static GetScreen() method in the Screen class that any other class can call to obtain the single instance of the Screen ...


2

You can store the values in a database,It is simple if you use database like sqlite but that wont work with libgdx -android. Instead you can use gdx-sqlite gdx-sqlite is a cross-platform Libgdx extension for SQLite database handling. The extension abstracts databse handling to provide a unified method to handle database transacitons across multiple ...


2

The parameters control which axis the image will be flipped around; sometimes you only want to flip around one or the other axis, instead of both. The first parameter, if true, causes the image to be flipped in the X direction (horizontal flip) The second parameter, if true, causes the image to be flipped in the Y direction (vertical flip). If both are ...


1

The screen coords go from {-1,-1} to {1,1} but you are most likely feeding it {0,0} to {1,1} - hence the fact that only one-quarter of the screen gets rendered. So just to be clear - point {0,0} is not the top-left (or bottom-left, depending on your co-ordinate system) point; it's the center. This also explains the texture coord tranformation that you are ...


1

If you want to use sqlite with libGdx you can use opensource project gdx-sqlite . gdx-sqlite is a cross-platform Libgdx extension for SQLite database handling. The extension abstracts database handling to provide a unified method to handle database transacitons across multiple platforms while also adding SQLite support for desktop version of Libgdx ...


1

The difference between ScreenSize and WorldSize is part of the brilliance of graphics systems like OpenGL. ScreenSize is the actual size of the window in pixels. When the user grabs the window handles and resizes the window, then ScreenSize will change. WorldSize is the size of your game level or "World". It is completely arbitrary. In a 2D game, 1 unit in ...


1

The nice thing about the Factory pattern is that the base class can be abstract and you can have different derived Factory classes. That means you can have an ExplosionFactory, a BulletFactory, an EnemyFactory and so on, which all inherit from the basic class GameObjectFactory. Any code which is common to all objects would be in the GameObjectFactory while ...


1

Did you clear the screen? You have to use glClear() method to clear the screen before drawing the current frame. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Hope this helps.


1

I assume that you are calling update() once every frame, before you draw the frame. Your problem is that you are doing either the collision correction or the movement every frame. You need to do both. What's happening is: Your character checks if it is below the screen bounds, it isn't So it moves below the screen bounds, draws for one frame below the ...


1

Ok, after 4 hours of searching finally I found the mistake. Problem was with the sprite origin. Here's the line that was necessary (staticBody is the body around other bodies will rotate) tmpSprite.setOrigin(staticBody.getPosition().x / 32 + tmpSprite.getWidth() / 2, staticBody.getPosition().y / 32 + tmpSprite.getHeight() / 2); And here's ...


1

Boolean fullScreen = Gdx.graphics.isFullscreen(); Graphics.DisplayMode currentMode = Gdx.graphics.getDisplayMode(); if (fullScreen == true) Gdx.graphics.setWindowedMode(currentMode.width, currentMode.height); else Gdx.graphics.setFullscreenMode(currentMode);


1

I needed to do the same thing and went for an extremely simple solution in the end and it seems to work well. I created my own StageExtension class that extends Stage (for other reasons), but within this I simply override the touchDown method adding 2 lines; @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { ...



Only top voted, non community-wiki answers of a minimum length are eligible