Tag Info

Hot answers tagged

18

Storing the completion information in a local file is a simple and perfectly acceptable method of doing so. Fundamentally, this is what every game will do to track progress (in some fashion, although the specific formats used for the data and the storage mechanism will differ). Protecting the file from tampering is more difficult. If there's no compelling ...


15

Think of the problem like this: How does a snake move in the original game? The snake moves towards its current direction. The behavior looks like the head appears out of nothing, and the last tail part disappears. You can have a list of snakeparts. What you want to do is remove the last item in the list which represents the last tail part. Then you want ...


10

The PNG files are small because they are compressed. When the images are loaded into memory they are uncompressed and therefore take up more space.


9

You can create a replay file as proof of work while the player is playing. Start the game, save the starting conditions including the name of the level and the pseudorandom seed, record the exact timestamped input states (mouse movements, key or button presses, etc.) that your game's input layer passes to its logic layer, and stop recording once the ...


8

It defaults to locked on "landscape" mode in a libGDX project. You need to go into your "AndroidManifest.xml" and change android:screenOrientation="landscape" too android:screenOrientation="sensorLandscape" There are more options - http://developer.android.com/guide/topics/manifest/activity-element.html#screen Just replace "sensorLandScape" with the one you ...


8

No, you don't have to use any specific toolset and you don't have to use any specific (physics) library either. It's just a question of convenience, since things like Box2D will provide you other benefits as well, e.g. being able to do collision, physics simulation etc. If you're not using tiles, you'll most likely want to write your own custom editor. As ...


7

Option #1: Split tubes into 2 parts, the tube and the rim. So that you stretch the tube to be as long as you need it and the rim part is always the same size. Option #2: Make the tubes to be always the same length and hide the ends behind the walls.


6

This is actually really simple. All you have to do is add another ClickListener which listens for Right Clicks (the default only listens to left clicks). To do this all you have to do is this: someButton.addListener(new ClickListener(Buttons.RIGHT) { @Override public void clicked(InputEvent event, float x, float y) { //do whatever } ...


5

After banging my head against this problem for a day I found a wonderful tutorial on the very subject over at Sion Dream. I knew there was a way to use object layers! In a nutshell, create an objects layer on your map (Tiled, Tide and the tutorial author's pick, Gleed, all provide this function), draw the shapes you want your Box2d static bodies to be, then ...


5

The new project generator comes with autogenerated .gitignore file like: ## Java *.class *.war *.ear hs_err_pid* ## GWT war/ html/war/gwt_bree/ html/gwt-unitCache/ .apt_generated/ html/war/WEB-INF/deploy/ html/war/WEB-INF/classes/ .gwt/ gwt-unitCache/ www-test/ .gwt-tmp/ ## Android Studio and Intellij and Android in general android/libs/armeabi/ ...


5

Disclaimer: I have not used libgdx or Java before, this answer borrows syntax from the question and official documentation, and the code is untested To make the bodies 'fall' under the influence of gravity in box2d, you must first pass a non-zero gravity vector to the b2World when constructing the world World world = new World(new Vector2(0, -10), true); ...


5

If you are using LibGDX, you need to forego the concept of Activities and Views, since your entire game will now just be a single Activity. To have a main menu when you game starts up doesn't switch the Activity, but just presents a different set of objects to be rendered to the same Activity. The easiest way to accomplish this would be to do the following. ...


5

It's easy: Fonts do not need to match resolution, they need to match pixel density. Pixel density is measured as pixels per inch(PPI), or pixels per centimeter. There's also a measure unit called density independent pixels(DP). 1dp is the size one pixel has on a 160 PPI screen. Now coming back to fonts, try to make this test: put your laptop to run on ...


5

There are three main ways (that I know of) to obtaining input in LibGDX. The first is as you said, changing the ClickListener, the second will be setting the setting the current screen as an implementation of InputProcessor , and the third will be obtaining the mouse click through a new class, or a sub-class to get the input. I'll elaborate on each: The ...


5

You seem to want to keep the same textsize/screensize ratio. Basically what you do is develop at one resolution and let that be scale 1.0. Then you divide the new screen width by the old width and that is your scale factor. For example. Developing on 2560x1440 with font size 16 and running on 1920x1080. Font size will be: 1920 * 16 / 2560 = 12 I do the ...


5

I assume this is because in these cases the grid lines are not exactly on screen pixels, but somewhere in between. Is this correct? Yes, this is correct. The camera in LibGDX is based on a vector, which is made out of floats. When your camera is in between pixels (like at (1.2f, 63.5f)), then you will start to see that blur you mention because the ...


5

The problem is you need to close the loop, to make sure the lasso is complete (based on the behavior of the video). You do that by testing if one of the segments intersect with another segment, thus closing the loop. It might look something like this (note I don't use libgdx, so this is untested): Array<Vector2> path = p.getPath(); // Look for an ...


5

It's because you're doing integer math in the first case, but not in the second. First, a quick look at the documentation getWidth int getWidth() Returns: the width in pixels of the display surface. < getHeight int getHeight() Returns: the height in pixels of the display surface So now we know that the two methods return integer ...


5

Here's a vector-based solution. I haven't tried it, but it seems fine conceptually. Theory I gather you've stored the shape as line segments. Here's the letter A represented with three line segments. I've assumed that paths in the user's drawing are stored as lists of points. We can "inflate" those line segments to allow an error margin when checking ...


5

Sarting with the clouds, a simple method is to draw them as three layers: Layer 1 is the bottom layer, and is drawn first. It just contains the cyan background. Layer 2 is the middle layer, drawn between the other two, and it represents the 3D highlights. The background in this layer would again be transparent (represented by a purple colour in the ...


4

Simple Solution If you want the body to instantly rotate just call Body::setTransform and pass the current position and the desired angle, don't bother applying torques or anything. The function call could be something like this: body.setTransform(body.getPosition(),myDesiredAngle); Physics Solution If you want the player body to interact with bodies ...


4

The particles themselves associated with a particular effect shouldn't be tied directly to the object. While there is never a 100% use-case scenario, this still applies to most situations. Your object itself shouldn't be managing the life-cycle of a particle effect, though it may be the instigator for spawning particular effects in the world. So, in your ...


4

At the moment, you're moving the piece with a linear interpolation. That means that every timestep, the tile's position changes by the same amount. position = position + translation * timestep You could use any function there: position = position + translation * f(timestep) Then the position changes by an amount determined by the function f. There ...


4

Alright, so you're working with two rectangles here. A larger static one (the map) and a smaller moving one (the camera) inside of it. What you want is to not let the bounds of the smaller rectangle move outside the inner bounds of the larger rectangle. // These values likely need to be scaled according to your world coordinates. // The left boundary of ...


4

I tried it out in RUBE and the Prismatic joint works fine for me: What you may not have realized is that you can set joint limits on the prismatic joint, which makes this a lot easier to set up. You can tune this by playing with the mass of the block, and the linear damping. You might also want to set the coefficient of restitution to zero.


4

The particle system solution is likely the one you want as creating and maintaining 100+ sprites with varying positions and gravity is exactly what a particle system does. Only it will handle object re-use for you automatically which will help make it as efficient as possible. Just create a line emitter that covers the entire width of your viewport. ...


4

So in general, JSON works really well for storing parameters and settings, but for storing big blocks of data like tile maps, you'll probably want to use your own format. JSON can be really repetitive, storing 256K copies of the string "GRASS_TILE", and that could be part of what's causing the slowdown. Using a SQL database probably isn't what you want to ...


4

I don't know if it is because of a poor component that causes the false readings or a extremely precise component that registers the spinning of the earth, as it orbits the sun, as our solar system spirals through the galaxy. Either way, this is a common problem. The solution is to use some type of filter to smooth out the "extra" readings. There are ...


4

You should consider using a plain 2d-array or alternatively an array of rooms, where each room is a 2d-array or a grid. A grid would looks something like this: The player is the yellow dot and the blocks are the green ones. if the player is the light gray square, you only need to check for blocks that around that square area. This saves you the time of ...


3

You could keep it simple. Methods: Randomly generate platforms, if a newly generated platform's position is overlapping, simply don't use it and randomize another position. It will work unless the platforms are very dense which they should not be. Another way to do it is to use slots across the Y-axis and never use the same Y slot. For instance if the ...



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