Player = new PlayerShip(new Image(atlas.getRegion("playerShip"))) Var atlas:TextureAtlas = TextureAtlas.loadTexturePacker("atlas/atlas.xml")
#Texturepacker tutorial full#
Here's the full code to it: import .TextureAtlas However, they are usable in this case because these strings do not represent actual keys, but key groups, which are declared earlier.īy earlier, I mean the MainScene class. Notice what values I pass to the check() methods - string values like "up" are not valid key identifiers by default. The update() function has movement logic, which checks for inputs using the Input class. I use the HXP class' properties to center the spawned ship in the center of the bottom of the screen. This means that we'll have to pass the ship graphic here later. You can see that the constructor receives a graphic object as a parameter, and sets it as the graphic of the Entity. If (this.y > HXP.height - height) this.y = HXP.height - height If (this.x HXP.width - width) this.x = HXP.width - width
![texturepacker tutorial texturepacker tutorial](https://i.pinimg.com/originals/7f/09/9b/7f099bdab16836b0b3ede26ef1df2319.png)
Let's make a moveable player ship entity, which will use the first graphic from the atlas.Ĭreate a new PlayerShip class. Now we have an atlas graphic and an atlas xml file. Once again, if you use a program like TexturePacker, this xml will be generated automatically, but you can write it yourself, as long as it looks like this: This is where we will define the regions of the atlas which represent different graphics. Now create an assets/atlas/ directory and place an atlas.xml file in it. Firstly we'll add the atlas with all the graphics packed in it. In this case I disabled window resizing, changed the background color, and, most importantly, I added an asset path to the assets/atlas directory. The xml file is used to define the regions.Ĭreate a new HaxePunk project, and edit the project.xml file right away.
#Texturepacker tutorial software#
You can create this image yourself, or use a software like TexturePacker, which creates an atlas and an xml file from provided graphics. The resulting image is called an atlas, or, in some cases, a spritesheet or tileset.
![texturepacker tutorial texturepacker tutorial](https://www.yopsolo.fr/wp/wp-content/uploads/2018/06/tiles.png)
This concept exists it most platforms that are used for game development. Texture packing is not a new concept, I previously explained it in my tile based game creation tutorial.īasically, texture packing is taking multiple graphics resources and stuffing them onto one image, which can then be fed to the GPU and sliced up in regions, which are then used as separate graphics. If you haven't installed HaxePunk yet, do so by following this tutorial. Today we'll cover packing textures into atlases for hardware rendering, as well as movement of our space ship. In this tutorial series I'll be making a simple vertical shooter game.
![texturepacker tutorial texturepacker tutorial](https://media.indiedb.com/images/articles/1/197/196907/auto/DDPaM6A.png)
HaxePunk is a game framework, so the best way to learn its features is by making a game. HaxePunk shooting game tutorial: Part 1 25.