Tag Info

New answers tagged

1

A nice way to implement what you are trying to achieve would be to use a SequenceAction and built in libgdx actions : tooltip.addAction(Actions.sequence( Actions.show(), Actions.fadeIn(1f), Actions.delay(4.5f), Actions.fadeOut(1f), Actions.hide()) ) Actions.show() basically call setVisible(true) on your actor and Action.hide() call ...


0

I don't see any new Spring calls in the code you posted, if the springs are being instanciated in the getSpring method then you need to ask yourself if you always have to return a new instance. With Vector2 for example, it comes with a set method, so you can have a temporary (or many) instance in your class that you work with when doing vector math, so you ...


0

public void getInput(int delta) { if(Keyboard.isKeyDown(Keyboard.KEY_A)) camX-=1; } Is usually: float camX; float speedPerWholeSecond = 1; public void getInput(float fractionalElapsedSeconds) { if(Keyboard.isKeyDown(Keyboard.KEY_A)) camX -= (speedPerWholeSecond * fractionalElapsedSeconds); } This calculation is made FrameRate ...


0

You just forget to enable vertex attrib with glEnableVertexAttribArray before calling glVertexAttribPointer int vertHandle = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertHandle); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBufferVAO, GL15.GL_STATIC_DRAW); **GL20.glEnableVertexAttribArray(0);** GL20.glVertexAttribPointer(0, 3, ...


0

Other information, the default constructor for the mat4 class is putting all the values to 0 This is incorrect. Your default matrix should be the identity matrix instead; i.e: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1


0

If you just want to create a "SettingsActivity" and a kind of main menu for your game : why not, you may save time indeed. You can start as much custom activities as you want from an Android LibGDX project. The libgdx launcher class usually generated in templates project is just an activity. So it's technically possible to start other activities and Android ...


-1

I fixed it by updating gdx-tools.jar. Oops.


2

Because of type erasure you lose the compile time type information of generics when transmitting data over network. If you need it on the receiving side again, you have to put the type information back yourself somehow. It's impossible to say how you should do this, but typically it involves either enums or class names and some type casting.


1

Are all coins doing the same animation? You could make a method in the Animation class that takes a coin as an argument, then performs the animation on that coin. Then, on another class, you make a loop that traverses the coin list and calls the method in your Animation class, therefore animating each coin as you go through the list. You can also add delay ...


1

Create two dimensional array Randomly place mines and place mine location to list Foreach mines and add +1 to adjacent cells Mine creation int x = random.next(min, max); int y = random.next(min, max); mineList.add(new XYClass(x,y)) Number calculation Foreach(XYClass xy : mineList) addPlusOneToAdjacentCells(xy); This way, you don't even have to ...


2

I think the fastest method will be by not generating the numbers at board generation (I know it's almost cheating). It's most likely fastest to only generate the number when the player clicks on a square rather then during board generation. Secondly consider how you are going to generate mines, is each place on the board going to pass a check (loop over ...


1

The way I solved this a long time back (I forgot about this question entirely until now), was that I just basically checked if the boxes intersected, because the rotation was just for a first person camera. So it only would have effected the viewport and movement code, the actual collision was just checking for an intersection. Basically, it was just me over ...


2

JNI is a way to go if you want full access, but the Steamworks Web API might be an easier way to go. It's basically an HTTP/HTTPS-based channel to the Steamworks functions, designed to be instantly compatible with access from Java, Python, Ruby, and really anything that isn't intrinsically C/C++. Of course you know that the issue with JNI is that you would ...


0

It's pretty simple. All you need is something like this: // It's always good to keep variables around instead of inlining // magic numbers. int gridSizeX = 20; int gridSizeY = 20; // The rectangle starts getting dragged at startX, startY, // ends dragging at endX, endY // Like this: // +-------------------------+ // | startX, startY | // | ...


0

You can also take a look at one of Notch's LD game's source code. He implemented the behaviour you are talking about in this project: Minicraft


0

If you ignore the constants you have in your calculations (such as tile width, for example) the calculations for isometric to cartesian and back are usually; float isometricX = cartesianX - cartesianY; float isometricY = (cartesianX + cartesianY) * 0.5f; And the reverse is float cartesianX = (2.0f * isometricY + isometricX) * 0.5f; float cartesianY = ...


0

It looks like you are trying to put these actions in a SequenceAction, put both move and alpha action into a ParallelAction which then put into your sequence. actor.addAction(Actions.sequence(Actions.parallel(moveAction,alphaAction), moreActionsInSequence)); Also consider using VisibleAction (Actions.show/hide/visible) instead of alpha 0 for hiding ...


0

This is a broad question because there is no "best" way, but a good way to do it, if you're using Scene2D (which I highly recommend if you're making anything that is 2D) is to create a new Actor every time damage is done and add it to the stage. The actor should probably extend Label and upon creation add Actions to itself that cause it to rise and then fade ...


0

Wow wow wow. So clear() removes all children, actions, and listeners... All I needed to change was clear() to clearChildren()...


1

Your basic OBJ, or Object Wavefront file only contains geometry data - vertices, normals, texture co-ords, and optionally material data in an second file. It does not contain any sort of skeletal structure or motion data. Collada on the other hand contain both geometry data and optionally skeletal structure and motion data, along with scene information (eg ...


2

It's a bit inconvenient: You have to create each array manually, along each dimension: Create an object array with size sizeX, with element type [[I (a 2D int array) At each entry of this array: Create an object array, with size sizeY, with element type [I (a 1D int array) At each entry of this array: Create an int array, with size sizeZ Here is an ...


0

Don't use a variable time step for physics, this will mess up the entire engine. Box2D will attempt to apply enough force depending on the level of penetration, if the step is constantly changing then Box2D is getting different numbers each time it tries to separate fixtures. Use an fixed timestep instead: world.step(1f/60f, 5, 8); Or some other ...


2

First your use of the aspect ratio is nonsense. The aspect ratio is the relation of width to height. So if you have float aspectRatio = (float)myGameHeight / (float) myGameWidth; This means that the the following is true: myGameHeight == aspectRatio * myGameWidth If you want to preserve the aspect ratio of the screen you need to do the following: ...


1

first you transform the cannon ball into the coordinate space of the ship. Then you act as if you want to add the ball's model to the octree and step down through the nodes. If the ball straddles a boundary line then go through both sides. Once you get into a leaf not then there is the bucket with faces to test with.


1

There are a few steps that you need to follow to accomplish this goal, they are as follows: Get the distance that the player has traveled (ie the amount of time the w key jas been pressed times some sort of speed multiplier) Calculate the length of each of the sides of the right triangle that's formed by the relation of your mouse cursor to the position of ...


0

What do you want to prevent? Editing or reading? Preventing reading is impossible. Your client has to be able to read and display the images and text files to allow playing the game, so everything someone would need to crack any protection you add would always have to be included in your client software. If you want to make it less tempting for a user to ...


0

As the game executable has to be able to decode the data to use it, there is no protection from an user determining the decryption key and doing the same to read the data. You can get limited protection from modifying files by encrypting them with a private key server-side, as the user will not be able to encrypt new data in a manner that is decryptable by ...


0

Try using vector math instead of cos/sin angles. Something like this might work for you; public void moveAlien() { float velocity = 50; Vector2 ap = new Vector2(AlienBody.getPosition()); Vector2 mp = new Vector2(Marinebody.getPosition()); Vector2 delta = mp.sub(ap).nor(); // This is not a unit vector pointing in the direction from ap to mp ...


0

You could move the background or make a new orthographic camera. Then do some thing like camera.setPosition(player.x, player.y);


0

I'm no too sure of the overall design of your game, but I don't see why you would need GameWorld or GameRenderer classes since Screens generally accomplish such tasks. To separate the player and keep collision detection you can simply require the instance as an argument: private void checkCollisions(Player player) { for (Drops e : getDrops()) { ...


0

LibGdx is taking care of the FPS itself, there's no need to for you to intervene. remove all the fixing methods, your delta time is now - gdx.graphics.getDeltaTime() use only it (send it to world.step())


0

To implement a spring I would do this: On the spring-player collision detection Give an impulse to the player toward the desired direction Disable the spring Let the gravity take care of the rest Re-enable the spring after on or more conditions: After a certain delay After the player is no longer colliding with the spring After the player is ...


2

After days of stress, I've finally fixed the problem. After performing a backtrace on the main thread I discovered the program came to a halt when trying to load the Google Analytics trackers. This is the thread backtrace: at com.google.android.gms.analytics.ae.getLogger(Unknown Source) at com.google.android.gms.analytics.ae.W(Unknown Source) at ...


1

Calculating the vector that points from a spring at point A = (x0, y0) to a spring at point B = (x1, y1) is simply: v = (x1 - x0, y1 - y0) Assuming no other forces acting on the player, then changing the player's velocity to some scalar multiple of v when they hit spring A would direct them to spring B. If another force like gravity is involved, then, ...


0

I guess what the user on your other question suggested was something like the following. Your interface provides the method move public interface SeekArriveMovement { void move(); } which is implemented by your Player class public class Player implements SeekArriveMovement { @Override public void move() { // do something } } In ...


0

Stop using pixels and use virtual units. Remember that if you don't have camera.unproject(); in your input processing code then you have bad input processing code.


0

Moving background has better performance than moving camera. On the other hand, moving camera is more intuitive and that's what we see in real life.It's all up to you.


1

That is right idea for reading/writing images but you'll want to get your "ImageLoader" class from a library, which will then give you a regular bitmap in memory to work with. The layout of that bitmap class is going to depend on the library you use. To see why, or what you need to handle if you want to write your own, see the W3C PNG Specification.


0

One method you could use is instead of assigning a random rotation to orientantion, you should increment or decrement orientation by a small random amount. Pseudocode: orientation = orientation + (randomFloat() - 0.5) * VARIANCE


0

I will give you a different approach you might wanna try. How i would do this is I would use shapes for the objects. A rectangle for the terrain, a rectangle for the bottom half of the worm and a circle for the top half of the worm. So the worm is a combination of 2 shapes. Now, if the user presses left worm gets a (-5,0) velocity if the user pressed up the ...


0

currentTimeMllis returns a long for the number of milliseconds since Jan 7, 1970 (~1,425,579,434,000 at the time of this post!), not an int since program start, so that might be one problem. Also, minor point of clarity, I'd suggest using something like: long nextShot = 0; long recoilTime = 1000; public void tick() { if(input.shoot && ...


2

How many milliseconds since Jan 1 1970? About 1425579436439. That's more than fits in a integer. You need to use a long.


1

The issue is the else condition after you check the A and D keys, since if no key is pressed it will reset the direction to 0, 0 every time the update() method is called. Instead of calling moveLeft() and moveRight() in the touchDown and touchUp you should keep track of each pointer passed by the touchDown and touchUp methods and check whether the pointers ...


0

It seems to me like what you want is a slerp function, see: http://en.wikipedia.org/wiki/Slerp


0

I'm just getting into libgdx/scene2dui as well, but maybe I can offer some help. I found using tables quite handy and accurate. It also has the benefit of relative positioning of objects. I don't know about CSS, but why would you use absolute positioning, it screws up if you want the game to be playable in different resoultions and aspect ratios and makes ...


0

your calculations should go into the update method. it's fine to have an AIManager class, that has an update() method itself which gets called in the main update loop. this AIManager could hold a list of all the Objects that need to be updated. Since you're using java, you could use an interface to declare something to have an AI, and use this interface to ...


1

If you're also working with box2D, you could try box2Dlights, it's a pretty nice wrapper and it's easy to implement as well.


0

That's how I do it in my 2D fighting game: The characters object holds only their physics values (position, velocity, acceleration and friction). Each character contains a set of states (standing, jumping foward, jumping back, weak punch etc.) When a character change its state, the 'Initialize' method of that state is executed. Inside it I can set the ...


1

Yes, you'd essentially create a bridge - no wrapper - but that's terminology. The basic idea is to use two network connections. You've got one listen port that will act to the actual game as if it was the actual game server. The bridge will also establish a connection to the real server and pretend to be the actual game client. The rest is pretty ...


1

A simple approach might be to first resolve the movement in the X axis and after that in the Y axis. This way you'll always know which component of the movement caused the collision, and you can resolve the collision for that component without even having to touch the other one. For instance: This will make sure we don't pull movement out of nowhere. Keep ...



Top 50 recent answers are included