Tag Info

New answers tagged

0

You could pretty easily manually type up an atlas (the metadata pack file that TexturePacker generates.) It's just a plain text file with entries that point to specific images contained in the packed png. Look at a sample .atlas file and just Notepad++ up your own that imitates the format and points to the individual sprites on your sheets.


0

I see you use gridSprite.setSize(SIZE, SIZE);//4x4. That means that your sprite uses 4x4 units of your camera's viewportWidth and viewportHeight for drawing. And that means, that your world is scaled. If you were using viewportWidth and viewportHeight set to screen resolution in pixels, then text will be all right. But when the world is scaled, viewportWidth ...


0

I figured out the solution. The problem was that Listeners would work only after we set a bound to our Actor. I hadn't set any bounds, so it was not taking the touches. Now I set the bounds in the draw() method(so that it will get updated each time the actor moves) and it is working like a charm. @Override public void draw(Batch batch, float parentAlpha) { ...


0

I searched the wiki for an answer and found that there is no Loader for text files (see list here). So I followed the instructions on the same page to write my own loader (the instructions can be found here). This is what I came up with: The Text class is basically a wrapper around a simple String: package mygame.assets; import ...


0

As you automatically generate these color definitions, maybe you could generate it instead of loading from a file. If the problem loading is the size of the file, you could consider using compression. But as you wanna try with assets loader, I'll add some links that could be useful. To manage these color definition assets you could write your own loader. ...


0

You should do a bounds check as you mentioned then reduce the velocity so you don't get shaky behavior. You kind of got it but I'm not sure what displacement does. //This code goes after velocity is set if (position.x > 50) { position.x = 50; //If we're heading towards the bounds, stop if (velocity.x > 0) velocity.x = 0; } else if ...


0

You need to create an InputProcessor (or an InputMultiplexer) and register this with the LibGdx backend. You then add your InputListener & Stage to this InputProcessor. This is a typical use of the function: Gdx.input.setInputProcessor(inputProcessor); Read this page for more information https://github.com/libgdx/libgdx/wiki/Event-handling


0

There was a post explaining the changes, but is not easy to find. The link was on the 1.5.6 release changelog: http://www.badlogicgames.com/wordpress/?p=3666 And the link about changes in fonts was: http://www.badlogicgames.com/wordpress/?p=3658 private static GlyphLayout glyphLayout = new GlyphLayout(); private BitmapFont fontA = new BitmapFont(), fontB = ...


1

Do you want the objects to move along the X axis (right to left) at the same speed or should this vary? If it should be the same speed, simply apply some sort of random modification to their Y velocity every X frames while keeping the X velocity at a constant. If they should slightly vary in speed from left to right, do the same as above making sure to ...


0

Here is a pseudo theory on how to write it. Base on the lines drawn the max value for the Y-axis when generating random values is based off of the most extreme points from the object's center. You will also need a timer to set check distance. a more advanced version would be to apply random time to the below pseudo code to trigger more random variations ...


-1

Try using ChangeListener, i've never used a ScrollPane but I did some UI's using ChangeListener!


0

First of all you should use a DebugRenderer for testing your Box2D world. Otherwise you will have a hard time figuring out what your world is actually doing: Box2DDebugRenderer debugRenderer = new Box2DDebugRenderer(); //the below code goes at the end of the render method: debugRenderer.render(world, camera.combined); Then another thing that catched my ...


0

I have done something like this and works great...thank you all..for your valuable suggesitions initiate() { bg1=new Sprite(backgroundImage); bg2=new Sprite(backgroundImage); } update() { position1=position1-3; position2=position2-3; if(position2<=-height) position2= height; if(position1<=-height) position1=height; } render() { ...


0

In my game i have 3 background textures (maximum amount that can fit on screen). I initialize them so they are placed in a row. And this is how i update them: protected void updateBackground(Background background) { if (background.position.x < camera.position.x - (background.width + camera.viewportWidth / 2)) ...


0

I would have one background sprite. Then offset the uv of that sprite for when the camera moves. The sprite's texture will have to be set to repeating. The background sprite will need to be locked to camera position. Very similar to this Repeat texture in a scrolling game


0

This is what I use to check collision between circle / rectangle. Note that this doesn't do continuous collision detection. Which means that if both of the shapes are unproportionally small or the objects are colliding with really high speeds (because you have too low fps and you use Delta Time to calculate the velocity for example), then the collision ...


0

It's not a good idea to dispose/destroy your objects unless you want to change your screen (for example moving from menu to game level ) because when your are disposing/destroying objects , garbage collector is called ,so it's better to store your dead objects in memory instead of destroying them. First off all read this article ...


1

Given that top left is at 0, and each tile is square with length 10: int squareClickedX = clickPosX / 10 int squareClickedY = clickPosY / 10 So, if clicked on x23, y12 int squareClickedX = 23 / 10 int squareClickedY = 12 / 10 results int squareClickedX = 2 int squareClickedY = 1 Means that you clicked Was this any good? This is quite common way ...


0

The delta time is the time since the last frame. Ofc, when you are debbuging, a frame takes verry long, as you are stepping through the code. Therefore the delta time can become huge. But keep in mind, that the delta time can become bigger then expected, even without debuging. Slow devices, f.e., can result in bigger delta times. So instead of "stopping" ...


1

A Stage has the 2 methods act() and draw(). The act() method calls act() for all it's Actors. The Actors act() method updates all it's Actions, so your screenshot is taken while the Stage is acting. The draw() method calls draw() for all (visible) Actors and is usually called after the act() method. The screenshot should be taken after the draw() method. ...


0

Just add a limit on the number of updates you can do between drawing, i.e. limit the accumulator. If it will never catch up for more than a second for example, you'll never run into this issue. Also keep in mind that this is essentially needed to avoid situations where you're never able to catch up again, which might cause your app I get stuck (time per ...


0

If you want your hit detection to be as accurate as possibly, you need to correctly set your actor's size and position. For your example, this would probably go something like this: The circle's constructor: public Circle(Texture tex, Vector2 position) { this.tex = tex; this.setPosition(position.x, position.y); this.setSize(tex.getWidth(), ...


0

There are documents in libGDX's github wiki https://github.com/libgdx/libgdx/wiki/Tile-maps According to this page, you can get your objects by finding the layer contains them. MapLayer layer = map.getLayers().get("my-layer"); Find your objects MapObjects objects = layer.getObjects(); And get the object objects.get("object_name"); There are many ...


1

What you need to do is assign a listener to the Actor (I assume you are using these). This is as simple as (if you are trying to detect clicks): myActor.addListener(new ClickListener() { public void clicked(args) {.... }); Then put whatever you want to happen in that clicked method. Make sure your game's input processor is that Stage! ...


0

First, you need to know the screen bounds: int screenHeight = getScreenHeight(); int screenWidth = getScreenWidth(); Then, you have to initialize the velocity vector for your bouncing square. In this example it'll be <1,1>: BouncingSquare bouncingSquare = new BouncingSquare(); bouncingSquare.velocity.x = 1; bouncingSquare.velocity.y = 1; Also, for ...


0

For my system I use a spritesheet with 16 tile variations on it. Upon creating a tile type I cut up the texture into regions specified in the constructor (which means my tiles can have varying resolutions). That means you can provide it with an image like this http://www.promagra.de/Downloads/Platformer/Pl5t.png and the transitions will take care of ...


0

Had the same problem with the following code: private void restart() { setScreen(new FooScreen); } Solved it simply by wrapping it in private void restart() { Gdx.app.postRunnable(() -> { setScreen(screen); }); } Hopefully that will help you.


1

You need to distinguish between the gl-viewport and the cameras viewport. The GL-viewport somehow defines the area on the Display, while the cameras viewport defines the area in the game world. So a camera with a viewport of (1/1) can see 1 unit of your world in width and height and projects it to the gl-viewport. For example: You have a Camera with a ...


0

Level designer is a full time job. Using an editor is really mandatory if you don't want to lose a lot of time. Most professional games like angry birds probably have teams that develops dedicated custom tools to ease their level designers job. Tiled : If i remember well, with Tiled Editor you can place shapes and manually set properties to them. You ...


0

Use ShapeRenderer http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html. Note that it's pretty slow and you'd better just use triangle sprite for that.


1

Here is an official Spine 2D example where they load Spineboy into a game. https://github.com/EsotericSoftware/spine-superspineboy The following 3 lines are used to read a texture atlas and skeleton data as well as making some animation state data. TextureAtlas playerAtlas = new TextureAtlas(Gdx.files.internal("spineboy/spineboy.atlas")); SkeletonJson ...


0

Think about having only one final Tile class and it defines only the data needed to render and update like the id of the Sprite or TextureRegion public class Tile { private int type; private int spriteId; some other data that you need and that belongs to a Tile ... public int getType() { return type; } public int ...


0

You can use an anti aliasing algorithm to fix it. One simple way to do AA is to take multiple samples per destination pixel when you down sample. Here's a link to one such method, called 4-rook ssaa! http://blog.demofox.org/2015/04/23/4-rook-antialiasing-rgss/


0

@Override public void create() { gameScreen = new gameScreen(this); setScreen(gamaeScreen); } Is the setScreen(gamaeScreen) a typo (gamaeScreen) ???


0

Having all Tiles be Actors that draw their sprite in the Actor's draw() call is an option. Of course there are many ways to draw a map, but this definitely is one of them. However I would warn against using Sprites. Since you said all tiles are 16x16px you will likely have very many of them in each level of your game. This would mean that you would have ...


2

The constructor of your gameScreen class does not initialize the camera and renderer fields, what you're initializing in the show method are method-local variables with the same names. That's why they're null when you're in the render method. Try changing OrthogonalTiledMapRenderer renderer = new OrthogonalTiledMapRenderer(map,unitScale); ...


0

Since you are using Actors you can simply give the actor an Action. For scaling you could use this method: myActor.addAction(Actions.scaleTo(scaleX, scaleY, duration); Then when the user stops pressing the button you can cancel the current action and give the actor a new one that scales back down to the original size.


0

To make this work you need the two stages to communicate. There are two ways you could have the result you desire. Have each actor you create (that is touchable) contain a reference to the HUD stage. Then when the actor is touched, simply update the HUD by calling a method with the actor as a parameter (hudStage.update(thisActor)). Do not assign listeners ...


1

When you "enter full-screen", the base window's border is removed and it is re-sized and moved such that its' ClientBounds == ScreenBounds. When this occurs, the Device is destroyed ("lost"), and needs to be recreated. At the same time, the back-buffer and any other textures or rendertargets that should be "full-screen" must also be re-created with the new ...



Top 50 recent answers are included