However taking part of picture as texture is possible.įirst generate pixmap from atlas texture. This is why batch.draw(Texture) and batch.draw(TextureRegion) are not same in use. When you get region from atlas its just saying that this is the area you gonna use (u,v,u2,v2) and this is original reference to whole texture. Import .scene2d.TextureAtlas actually not separating pieces. Oh, and be a good citizen and dispose of the filehandle on closing the app. Get the atlas from android internal assets directory, find the car and road regions, and make them all publicly available. Not a lot of assets in this game - just an atlas that contains a whopping great two texture regions. Import .g2d.TextureRegion Ītlas = new TextureAtlas(("images.atlas")) We also load our Assets, create a GameScreen and set it to active, and do some housekeeping on dispose. Our LibGDX Scene2D Stage will be stretched to fit the players device as best possible, which means our game will display nicely on devices with 320x240px screens, 1920x1080px screens, and anything in between! Note that these values aren't physical pixel dimensions, they are an abstract idea of the size of our play area. We'll later use these constants to set the size of our game stage. Package įirst we define static final width and height constants that will be used to specify the target resolution of the game. In the android projects src directory we have a standard MainActivity class generated by the LibGDX project setup tool - I've added an exit dialog to this class, but apart from that it remains unchanged. In the android projects assets directory we have an image atlas and its counterpart image file, these were generated automatically by the packing utility (it packs anything in the dev-images directory). In the desktop projects src directory we have a utility class that makes use of gdx tools TexturePacker2 (you'll only need to run this if you alter the textures - simply right click the desktop project in eclipse, run as java application, Pack Textures, then right click the android project and refresh), and a Main class used to start the game on desktop (generated by the LibGDX project setup tool and only tweaked very slightly). Right, so by now you've seen the live games on Google Play, installed the example project apk, and are interested in figuring out how it all works, let's dig in.įirst thing to note is that project is arranged in the standard core/android/desktop structure the LibGDX project creation wizard gives us. Provided you have your dev environment correctly setup, you can go ahead and import the existing project into eclipse and start tinkering :) If you need help on setting up your dev environment, check out this article. If you're interested in tinkering with the open source tutorial project, grab it from github. You can get the free multigame app that includes this minigame here ( free!).You can get a more polished version of what is essentially the same game here ( free!).You can get the example projects finished apk here ( free!).I'm hoping this mini project will be almost as simple and just as helpful to others! Street Race Swipe Racing Game is such a simple game at its heart that it seems like an excellent candidate for a tutorial article :) I remember being massively impressed by the example SimpleApp on the LibGDX wiki when first starting out, there was so little to it but it touched on all the basics of what is needed to make a game.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |