New answers tagged

0

Try creating an animation for the platform instead or in case the starting and finish points change you could try to use physics for movement and just check the position.


0

I was actually able to accomplish this by doing the following (there might be a better way than this, but it worked). This answer below is a bit specific to Box2D, as this was the original question's context. Here are the requirements we want When we make contact with the top of a platform, we want to enable the collision and stop the player If the player ...


2

I'm pretty sure you can deal with this by ignoring the collision if the y-component of the velocity is positive (the player is moving upward). Alternately you might be able to use the collision filtering flags. One-way floors are given their own contact group, and the player object can set/unset whether or not they collide with this group based on their ...


0

In general rigidbody physics is appropriate to model non-living things, while a completely different system of bone and animation based physics is usually used on living things and things which behave like living things (like robots or zombies). For example, if you drop a stone on the side of a hill you can model what will happen using a very simple system, ...


0

Swing / Java2D doesn't have a concept of a camera, but what you can do is store the transform of the camera, and apply that first before any other transforms. Also note that you are almost certainly going to run into unpleasant performance problems if you're not using an OpenGL-based rendering system. (I speak from years of painful experience.) I would ...


2

It could be that the attack timer never reaches 0 as the delta time will keep removing time which will eventually cause it to go negative. Instead check if the timer is less then or equal to 0 so if it goes negative the attack animation is stopped. else if (attackTimer <= 0f) Note: You should add an "f" behind numbers that you want to be floats because ...


0

I think that the most simple way of getting around your problem is as follows. I assume that your player entity helps you keep track of his state. Maybe it's running, or climbing or whatever you might have used. If you add to make sure that the only time you will ever check if the player sprite is on top of an enemy is when the player's state is falling, ...


1

Brief: The solution is not in collision listeners, but in collision filters. Collision filters have a shouldCollide method that you can implement to return false if you want to disable collision or true to allow it. Collision filters are executed before collision listeners. You can use, for example the linear velocity of the player sprite to decide if you ...


0

I found the answer: My game is actually very small but I resize it by a scale factor of 4. So I also have to divide the width and height of my bufferedimage by 4 inside the light render method public void render(Graphics2D g) { BufferedImage image = new BufferedImage(GamePanel.width / SCALE, GamePanel.height / SCALE, BufferedImage.TYPE_INT_ARGB);



Top 50 recent answers are included