FreeTexturePacker.Lib
1.0.0
dotnet add package FreeTexturePacker.Lib --version 1.0.0
NuGet\Install-Package FreeTexturePacker.Lib -Version 1.0.0
<PackageReference Include="FreeTexturePacker.Lib" Version="1.0.0" />
<PackageVersion Include="FreeTexturePacker.Lib" Version="1.0.0" />
<PackageReference Include="FreeTexturePacker.Lib" />
paket add FreeTexturePacker.Lib --version 1.0.0
#r "nuget: FreeTexturePacker.Lib, 1.0.0"
#:package FreeTexturePacker.Lib@1.0.0
#addin nuget:?package=FreeTexturePacker.Lib&version=1.0.0
#tool nuget:?package=FreeTexturePacker.Lib&version=1.0.0
Free Texture Packer Loader
A sprite sheet loader for using Free Texture Packer with Monogame
Read in another language : English, Français
Structure
There are four main classes to look at :
SpriteFrame: it represent one image inside of a spritesheetSpriteSheet: it represent the a collection on spriteframeSpriteSheetLoader: it is used to load the spritesheet generated from Free Texture PackerSpriteRender: it draws a sprite to the screen
The other classes are used to store information about a SpriteFrame:
Pivotstores the pivot point of a frameRectstore the (X,Y) position of an image inside of a sritesheet and that image size (Width, Height)Sizestore the size (With, Height) of the image
Getting started
Prerequisites
You must have Monogame installed.
For this example, I'm using Monogame 3.8.1.303
You must also have Free Texture Packer installed
For this example, I'm using Free Texture Packer 0.6.7
Installing
You have two ways to install it in your project
Use the sources
Simply copy theFreeTexturePackerLoaderfolder in your monogame projectGet IT through Nuget
dotnet add package FreeTexturePacker.Lib --version 1.0.0
Using Free Texture Packer to create a spritesheet
Open Free Texture Packer
Add the images in the
Examples/imagesfolderSet texture name to
chessSet texture format to
pngCheck the
Remove file extboxFor the packer use
OptimalPackerUncheck
Allow trimboxFor the format, choose
customClick the little pencil next to it
Paste the following export template :
{ "name":"{{{config.imageName}}}", "frames":[ {{#rects}} { "filename":"{{{name}}}", "frame":{ "X":{{frame.x}}, "Y":{{frame.y}}, "Width":{{frame.w}}, "Height":{{frame.h}} }, "rotated":{{rotated}}, "trimmed":{{trimmed}}, "spriteSourceSize":{ "X":{{spriteSourceSize.x}}, "Y":{{spriteSourceSize.y}}, "Width":{{spriteSourceSize.w}}, "Height":{{spriteSourceSize.h}} }, "sourceSize":{ "Width":{{sourceSize.w}}, "Height":{{sourceSize.h}} }, "pivot":{ "X":0.5, "Y":0.5 } }{{^last}},{{/last}} {{/rects}} ], "meta":{ "app":"{{{appInfo.url}}}", "version":"{{{appInfo.version}}}", "image":"{{{config.imageName}}}", "format":"{{{config.format}}}", "size":{ "Width":{{config.imageWidth}}, "Height":{{config.imageHeight}} }, "scale":{{config.scale}} } }Check
Allow trimandAllow rotationboxesFor file extension, write
jsonClick
SaveClick
ExportLocate the Content directory of your monogame project and click
Select Folder
It'll generate two files: chess.json and chess.png.
The first contains informations about the spritesheet such as the posistion and size all the images inside that spritesheet and the last file is the actual spritesheet.
Loading the spritesheet and using it with monogame
Create a monogame desktop project
Copy the
FreeTexturePackerLoaderfolder inside of your monogame project or add it through nugetAt this using line at the top of your Game1.cs file
using FreeTexturePackerLoader;Create an instance of the SpriteSheetLoader in the
LoadContentmethodvar spriteSheetLoader = new SpriteSheetLoader(Content);Create aninstance of the SpriteRenderer
private SpriteRender spriteRender;In the
LoadContentmethod, add :spriteRender = new SpriteRender(_spriteBatch);Load the spritesheet
private SpriteSheet spriteSheet;In the
LoadContentmethod, add :spriteSheet = spriteSheetLoader.Load("chess");Draw a sprite from the spritesheet In the
Drawmethod, add :spriteRender.Draw(spriteSheet.GetSprite("reine_blanc"), new Vector2(100, 100), Color.White);You should see the white queen at the screen
Now try to show all the chess piece at the screen.
You can find the full project in the
Example/ChessBoard Final
Contributing
Please read CODE_OF_CONDUCT.md for details on our code of conduct, and the process for submitting pull requests to us.
Authors
- Sesso Kosga - Initial work - senor16
License
This project is licensed under the MIT License - see the licence.md file for details
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- MonoGame.Framework.DesktopGL (>= 3.8.1.303)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 435 | 1/28/2023 |