I have read The guide to implementing 2D platformers
http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/
I want to develop the second way (Type #2: Tile Based (Smooth))
Collision is still determined by a tilemap, but characters can move freely around the world.
I have made a class Enemy with position and velocity.
How could I move the Enemy in the world when it is not visible in the screen yet? There is any GitHub example of this issue?
I am not using Box2D. I have started with the Super Koalio Example:
https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/superkoalio/SuperKoalio.java
My problem about rendering was solved using OrthogonalTiledMapRenderer
Related
I want to turn my player in the direction he is looking at. The whole is so similar to the behavior of the Bird in FlappyBird. He always looks in the direction in which he moves. I am programming this in Android Studio with libGDX and I have a class in which the game is played and one in which I have information about my player.
I have unfortunately no code example, because everything I have, would explain nothing and would make the situation only more complicated.
Please write a comment if you are confused.
Thanks for any help! :)
I think what you are looking for is a way to flip the sprite. Sadly, I don't think libgdx supports this. But what you could do is draw 2 images of your sprite(one in each direction) or use some drawing program to flip your current image. Then in your sprite class, in your update or render method you would change the sprite image to the corresponding direction using sprite.set(new Texture())
I am developing a multi-platform game on android studio using libGDX library and java language.
The game requires the player to maneuver a main ship across 2D space using mouse input.
I am using the given ParticleEffect class in libGDX library to show its exhaust but there is a slight problem that looks like this...
This is the standing ship
and
This is when its moving upward
I need every particle to move only downwards respective to the ship regardless the ship is standing or moving.
This means that I need to add the change in (x,y) coordinates of ship into each particle of exhaust but the problem is that the (x,y) coordinates of that class are private and there is no function that lets me make any direct changes to the coordinates of individual particles.
How do I make that happen?
Not sure, if I understood the question right. But probably, you can solve your issue via marking the emitter as attached. In this case if you change draw coordinates of ParticleEffect from (x0,y0) to (x1,y1), then every particle, which is already emitted, will be moved by (x1-x0, y1-y0) as well.
See the screenshot:
i am learning libgdx. i want to create a 2d fps game using libgdx, which is basically no physics environment. in that case lot of collision will be there (for example lot of bullets hitting multiple objects). i need to check intersecting of every sprite's rectangle with other sprites. in this way there may be thousand sprite's, checking every sprite with other 999 sprites in every time isn't definitely not a good idea.
libgdx has scene2d which has hit detection api's, is that solve my problem?
or
i should use box2d collision detection?
or
is there any other way to detect collision in libgdx?
i want to create a 2d fps game
As much as i know FPS means "First-Person-Shooter" -> a shooter with the first person perspective. That means, that it is 3D.
So pleas clarify what you mean.
Now to the collision detection question:
Scene2Ds hit detection is used for input like touch or
mouseevents. So it is used to detect, if an Actor is touched,
clicked...
Box2D is a 2D physic-engine which can not only do collision
detection for you, but it can also do the collision response as well
as the physics simulation (gravity and things like that).
Libgdx offers the Intersector class, which you could use for
overlap tests. The organization/the management of the collision
detection is up to you.
It would be better if you tell us how your game should work, how your world should be managed etc.
For example, if your world is tilebased, the collision detection between wall and player could be a simple check, if the tile is occupied -> collision, if not -> no collision.
Also it is important to know the shapes of your objects. A rectangle-rectangle collision detection is different from a rectangle-circle collision detection.
So now there are 3 solutions for your problem:
- Use Box2D and read tutorials on how to use it
- Do some research on collision detection, read tutorials and take a look at some sample projects
- Give us more informations about the game, its objects, their shapes etc.
I can do 2d collision detection of boxes and circles ,but I have a question . How can I do collision detection in this situation (1,2).I am using libGDX game engine for creating games.
Fixture (1) in your world should most likely be a ChainShape. ChainShapes are determined by an array of Vector2 objects, the more you have, the smoother the ChainShape tends to be.
Without very tedious scripting, making a fixture from an image is done by putting vectors at relatively close points to make a shape that looks similar to the image.
Further information on how to create a ChainShape can be found here.
I'm in the planning stages of game dev. and am wondering whether or not to pick unity or Libgdx. I already know quite a bit of java, and I want to make a 2D sidescroller that uses ragdoll physics with animation. I have been looking pretty hard, but haven't found a good resource for this yet with Libgdx. It seems possible with Unity though. The resources I have found so far with Libgdx are :
Rube
Glee2d
Spine
Blender
So far with this it seems possible to make a level with a skeletal 2d animating sprite, but is it possible to apply ragdoll physics to this creation so, for example, if an enemy was shot it would react like a ragdoll?
I appreciate any help!
Thanks,
You could clearly use libgdx for that.
You'd have to create the ragdoll as box2d bodies (which can be done with rube). For rendering the ragdoll, you could use the setUserData() methods in box2d to bind an actor to the body/fixture. After each simulation step you would update the actors and create the proper rendering.
You could then place the ragdoll somewhere and shoot it with some other box2d body, let's say a cannonball...