aristurtledev / monogame-aseprite Goto Github PK
View Code? Open in Web Editor NEWA Cross Platform C# Library That Adds Support For Aseprite Files in MonoGame Projects.
Home Page: https://monogameaseprite.net
License: MIT License
A Cross Platform C# Library That Adds Support For Aseprite Files in MonoGame Projects.
Home Page: https://monogameaseprite.net
License: MIT License
This is just to test the github to discord feed. No actual issue
Add support for runtime importing of the files without the need to build first with the content pipeline.
Aseprite Version 1.3 file format has changed. Importer/Processor needs to be updated to detect this change and handle file format appropriately
The links in the README.md file need to be updated to the new urls
I'm using a DirectX project because of Monogame's limitations wrt texture arrays on OpenGL.
This project's dependency on MonoGame.Framework.DesktopGL causes that project to run in OpenGL mode, giving an exception that texture arrays aren't supported.
Create a DirectX Monogame project, and add this line to its LoadContent:
Texture2D tex = new(GraphicsDevice,100,100,false,SurfaceFormat.Color,2);
add the Monogame.Aseprite nuget package, try to run the project.
It should run and display the monogame cornflowerblue hello world.
When the nuget package is installed, you get an error on the creation of the texture array.
You should in theory be able to not have the dependency on Monogame in the package, as Monogame.Extended does this too.
Due to the changes in the 2.0 update, all documentation will need to be rewritten.
Hi there, first let me thank you for this wonderful library.
Thanks to everyone who keeps this project going!
Scenario
Imagine a Lemmings-like scenario where you have multiple instances of the same animation. Since the animation is always the same, a single shared AnimationSprite should be sufficent to draw multiple characters at different positions. So far, this works as expected.
Problem
The animation of each character should be time-shifted, so that the animations do not run synchronously. Ideally there would be an offset that just shifts the animation in time. I have tried to forward and rewind the animation for each draw call with Update and IsReversed but nothing worked.
So, I'd like to suggest a feature that supports this use case - or find a workaround :-)
Hello
Monogame 3.8.1 is released recently.
Would it be possible to update monogame-aseprite so it works with 3.8.1?
Thank you
The pixel data from Aseprite does not have premultiplied alpha. The SpriteBatch
in MonoGame defautls to using a blend state that assumed premultiplied alpha. Processor needs to be adjusted to premultiply alpha for all Color
values to match what is expected by default.
When attempting to build any content using the MonoGame.Aseprite.Content.Pipeline.dll
reference in the mgcb-editor, an exception is thrown stating that it has no reference to the assembly MonoGame.Aseprite
mkdir ./example
cd ./example
dotnet new sln -n Example
dotnet new mgdesktopgl -n Example
dotnet sln add ./Example
cd ./Example
dotnet add package MonoGame.Aseprite --version 5.0.0
dotnet restore
# from within the project directory
dotnet mgcb-editor ./Content/Content.mgcb
Add the MonoGame.Aserpite.Content.Pipeline.dll
reference to the mgcb-editor as documented here https://monogameaseprite.net/docs/getting-started/setup-mgcb-editor
Add an aseprite file as content
Choose any processor from the MonoGame.Aserpite.Content.Pipeline.dll
reference
The content builds as expected
An exception is thrown stating that the MonoGame.Aseprite
assembly could not be found
No response
Add support for MonoGame 3.7 with the 2.0 update.
Both the AnimatedSprite.Update(float)
and AnimatedTilemap.Update(float)
functions have a parameter that expects the elapsed time in milliseconds. Using milliseconds is not a typical use case for delta time. Generally delta time is done in seconds.
The typical use case will use delta time as total seconds not total milliseconds
// Assume an AnimatedSprite was created during the LoadContent method
protected override void Update(GameTIme gameTime)
{
float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
_animatedSprite.Update(deltaTime);
}
It would be expected that the animated sprite updates accordingly using the common format of delta time being in seconds.
The animated sprite is not updated as expected since it assumes delta time in milliseconds.
Not applicable
No response
Tile's that are flipped in a TileMap do not render in correct orientation.
Make tileset in aseprite.
Make tilemap in aseprite, with some flipped tiles (hold space then hit x,y and/or d to flip a tile when placing)
Import aseprite file directly into Monogame (not using the content pipeline)
When rendered, you should see the 'flipped' tiles in odd orientations. Results may vary.
Rendered tilemap looks the same in Aseprite as it does in Monogame.
Rendered tilemap looks off when rendered, only flipped tiles are off. They appear in the wrong orientation.
Aseprite v1.3.2
Monogame 3.8.1.whatever (the latest one)
MonoGame.Aseprite library version 5.1.3.-beta-2 (the latest one)
No response
Latest version support
Up to date with aseprite
Is there any way to render a slice?
I'm using Monogame.Aseprite 2.0.3.3 and the the latest current Monogame packages (3.8.0.1641).
After adding the reference to the Monogame.Aseprite.ContentPipeline.dll in the content builder, I get an error when building stating:
Couldn't find a default importer for
'/build=/build/=reference../../../../Users/ME/=nuget/packages/monogame.aseprite/2.0.3.3/contentFiles/netstandar2.0/Monogage.Aseprite.ContentPipeline.dll'!
If I then add an aseprite file by adding an existing item in MGCB, I can assign the asprite importer and processor but the build fails with the same message and
"Failed to create importer 'AsepriteDocumentImporter'
on the imported aseprite file.
Workaround:
Edit the Content.mgcb file directly and remove the lines:
#begin /build=/reference:..\..\..\..\Users\ME\.nuget\packages\monogame.aseprite\2.0.3.3\contentFiles\netstandard2.0\MonoGame.Aseprite.ContentPipeline.dll
/importer:
/processor:
/build=/build=/reference:..\..\..\..\Users\ME\.nuget\packages\monogame.aseprite\2.0.3.3\contentFiles\netstandard2.0\MonoGame.Aseprite.ContentPipeline.dll
and change relative path:
/reference:..\..\..\..\Users\ME\.nuget\packages\monogame.aseprite\2.0.3.3\contentFiles\netstandard2.0\MonoGame.Aseprite.ContentPipeline.dll
to and absolute path:
/reference:C:\Users\ME\.nuget\packages\monogame.aseprite\2.0.3.3\contentFiles\netstandard2.0\MonoGame.Aseprite.ContentPipeline.dll
I'd like to have the option to pass a double instead of a float, for performance reasons.
Fix is basically to add this method in AnimatedSprite
:
/// <summary>
/// Updates this <see cref="AnimatedSprite"/>.
/// </summary>
/// <remarks>
/// This should only be called once per update cycle.
/// </remarks>
/// <param name="deltaTimeInMilliseconds">
/// The amount of time, in milliseconds, that have elapsed since the last update cycle in the game.
/// </param>
public void Update(double deltaTimeInMilliseconds)
{
GameTime fakeGameTime = new();
fakeGameTime.ElapsedGameTime = TimeSpan.FromMilliseconds(deltaTimeInMilliseconds);
Update(fakeGameTime);
}
Improving performance so I don't have to convert a double to a float every single Update call.
Documentation shows incorrect namespace as MonoGame.Aseprite.Processors
when it should be MonoGame.Aseprite.Content.Processors
Reference: https://monogameaseprite.net/docs/processors/sprite-processor/
Support new features from Aseprite 1.3-rc1. Release notes can be found at https://community.aseprite.org/t/aseprite-v1-3-rc1/17224
Things from the release note that will need to be implemented are
--tagname-format
). This might only affect the JSON export, so might not need to implement.The motivation for this is to update MonoGame.Aseprite to support the latest release which is Aseprite 1.3-rc1.
When any of the processors create a Slice
object for a TextureRegion
the constructor of the Slice
class takes in the Origin
as a parameter but the value is never set for the property.
TextureAtlasProcessor
or SpriteSheetProcessor
to process the Aseprite fileThe Slice.Origin
value for any Slice
element in any TextureRegion
to contain the data from the slice's pivot data in Aseprite.
All Slice.Origin
values are defaulted to Vector2.Zero
Not Applicable
This is occurring because the Slice.Origin
value is never set in the constructor.
Hi, I noticed the 'packages' folder doesn't get added when installing with NuGet on VS 2019.
I should mention Monogame templates don't work with vs2019 and I've had to use 'dotnet new mgdesktopgl' command to create project templates.
Luckily I have VS 2017 and just copied the packages folder from that. Just thought you might want to know
In the "Getting Started" section of the documentation, it recommends to the user that they should install nuget packages locally in the project, and then links to Microsoft's documentation about NuGet configuration. However MS's docs aren't always so clear. Adding a link to the sample project, or more specifically the nuget.config
file within the sample project might make setup smoother for users who aren't as experienced with NuGet configuration (read: me), or are otherwise running into issue with configuring NuGet to install packages locally.
https://github.com/AristurtleDev/monogame-aseprite-examples/tree/main
The auto generated XML documentation is not included in the version 4.0.0 NuGet package. Due to this, intellesense is not included for any types in the library.
dotnet new console -n Example -f net6.0
dotnet add package MonoGame.Aseprite --version 4.0.0
Program.cs
using MonoGame.Aserpite;
AsperiteFile file;
When hovering over the AsepriteFile
type in the example from the Steps to Produce section above, the intellesense should show the information included in the XML documentation like the <summary>
tags.
The XML Documentation is not included int he intellesense.
No other information to provide.
This library seems to implement two separate pieces of functionality:
As a separate package, the loader implementation could serve any kind of dotnet user, whether they're using the pipeline tool or not. The pipeline lib could then use this as a dependency and contain only the pipeline-related logic.
i tried to import .ase files in the mcgb content pipeline tool, but it used the OpenAssetImporter (wich obviously doesnt work here).
.aseprite extensions work but .ase would be good to have
easier use
Hi
I saw this page is offline
https://manbeardgames.com/monogame-aseprite/getting-started/monogame38installation
What are the correct install instructions for monogame 3.8 please?
Hello, I'm probably having an uncommon use case in my hands. I have an aseprite document with a single animation of 5 frames that I want it to run just once. I thought about doing this:
animatedSprite.OnAnimationEnd += animatedSprite.Stop;
but the animation loops anyway. I later found out the Pause method, but again it loops anyway with that too.
EDIT:
I tried OnAnimationLoop and it worked. I thought that OnAnimationEnd would fire after the last frame, my bad.
The RawTexture.Height
property is marked internal
.
Try to access the RawTexture.Height
property.
Access to the RawTexture.Height
property.
An error is shown that the property doesn't exist.
N/A
Reference line of code: https://github.com/AristurtleDev/monogame-aseprite/blob/main/source/MonoGame.Aseprite/RawTypes/RawTexture.cs#L54
Currently the import process is designed for importing animations done in Aseprite. However, Aseprite can be used to create other types of assets like static images, such as background or icons. Aseprite also has support for slice data and can be used for things like ninepatch buttons.
In the previous version of MonoGame.Aseprite
it was possible to add the text [oneshot]
to a tag in Aseprite, and then when it was imported, it was imported as a non-looping animation.
This was not carried over with the Version 4.0.0 update and should be re-implemented.
[oneshot]
at the end of the name. (e.g. open_door[oneshot]
AsepriteFile.Load()
SpriteSheet
with the SpriteSheetProcessor
AnimatedSprite
based on the open_door
tagAnimatedSprite
in the Update
method and draw it in the Draw
methodSince the tag has [oneshot]
at the end of the name, it's expected it to not loop in line with the previous version of the library.
The animation continues to loop
No other information to provide.
For platform specific context, such as Android, File.OpenRead()
is not well suited. MonoGame already offers a TitleContainer.OpenStream()
method that considers the platform context when opening a file stream.
Not using the TitleContainer
could lead to issues for users. This request is also being opened to track #47
User nobledemon reported on discord that AsepriteFile.TryGetSlice(string, out AsepriteSlice?)
is returning false, even when the slice name provided exists.
TestSlice
AsepriteFile.TryGetSlice("TestSlice", out AsepriteSlice? slice);
The method returns true and slice
contains the AsepriteSlice
instance found
The method returns false
and slice
is null
No response
This was brought up on the discord server by Mooosik
I noticed that if I hide a layer in Aseprite, the layer will be hidden in Monogame aswell.
Being able to do enable / disable layers in Monogame would be super useful but I dont think its
possible yet, is it?
For example if I have one walk animation with several types of hand poses on other layers (for carrying
different types of items), i could just set the layer i need to "visible".
So ideally here, what would happen is instead of flattening the layers to a single layer texture, each layer itself would be its own texture data. One hurdle I can think of for this is how the blending between layers would be handled.
Hi
Can wehave a bigger code example that is doing
Thanks
Support for importing an .ase/.aseprite file directly should be added instead of the current requirement of a PNG + JSON export from Aseprite for import.
NuGet package will need to be updated for the 2.0 release.
When I try to build a .ase file in my project when referencing this extension (I checked, it works without the .ase), I get the following error:
Unhandled exception. Microsoft.Xna.Framework.Content.ContentLoadException: The content file was not found.
---> System.IO.FileNotFoundException: Could not find file '/Users/gus/Projects/game-off-2021/src/GO21/Game/bin/Debug/netcoreapp3.1/Content/penguin.xnb'.
File name: '/Users/gus/Projects/game-off-2021/src/GO21/Game/bin/Debug/netcoreapp3.1/Content/penguin.xnb'
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Microsoft.Xna.Framework.TitleContainer.PlatformOpenStream(String safeName)
at Microsoft.Xna.Framework.TitleContainer.OpenStream(String name)
at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(String assetName)
I checked and the file isn't there, and it doesn't appear to have been built. I'm on macOS M1, and I'm using Visual Studio for Mac. Thanks for any help!
Hello
I first used this code for animations in monogame but now moved to aseprite
https://www.monogameextended.net/docs/features/animations/animations
Can you give me a code example on how to do display the sprites in Update() function there (for key movements and associated sprite) but by using monogame.aseprite code?
I can't find how to do it
Thank you
In order to facility allowing users to import and process files at runtime, need to look into changing the namespaces of both the MonoGame.Aseprite
and MonoGame.Aseprite.ContentPipeline
assemblies.
Currently all importing and processing is done through the
MonoGame.Aseprite.ContentPipeline.dll
library In order for importing and processing to be performed during runtime, users would need to reference that library in their game project as well as theMonoGame.Aseprite.dll
library.
The problem here is that both of these contain
.Aseprite
in their respective root namespaces, and it could potentially be confusing having the.ContentPipeline
namespace as part of a completely different assembly.
Would potentially need to rename the namespaces to resolve this, which would be a breaking change.
Originally posted by @manbeardgames in #7 (comment)
Every link in your readme is broken. It seems you got rid of your github docs but never updated the README.
When drawing to the spriteBatch, normally you can add the viewport size for it to scale. Is there an option for that here?
I'm using MonoGame 3.8.0, with Newtonsoft.Json and Cross-Platform Desktop Development installed. I'm making a Cross-Platform project (OpenGL). Whenever I attempt to compile within MGCB it does this:
The Newtonsoft.JSON errors appeared even before I had Newtonsoft installed. Any answers as to what's causing this problem?
Make it possible to edit animations, especially the IsOneShot parameter would be useful to edit.
Currently I made a workaround where I duplicate an animation like this:
if (treeAnim.Animations.TryGetValue("anim", out Animation anim))
{
anim.IsOneShot = false;
anim.Name = "anim2";
treeAnim.AddAnimation(anim);
}
treeAnim.Play("anim2");
Or is there a way to set oneshot animations from aseprite that I am not aware of?
Edit: I found your solution in #20, but I think it would still be useful to edit, delete or replace animations
First, I must divulge that I have a very unorthodox way of importing my content into my game :
I have one project for each platform I currently support : DX and GL.
I also have a Content project, which holds all my content and the pipeline extension dlls. Those get imported later automatically using NoPipeline.
In my DX and GL projects, I have Content/Content.npl
which is the file used by NoPipeline to create an MGCB file with all my assets from the Content project. It also automatically imports all the pipeline dlls like mentionned previously.
Here's the kicker : Your project isn't giving me your Pipeline dll in my bin folder, and I would need to refer to it from my .nuget
folder, which isn't portable. I strive to keep things portable.
So I figured, what the heck, might as well just include the dlls directly in my Content project folder, then set them so they get copied into the bin folder like the rest.
Well... that fixed it. So yeah, a bit of a pain but it worked. That's my issue number 1 : I wish we could import the dll from the nuget without having to use an absolute path to the nuget package.
2nd issue is this : None of my aseprite files build correctly. They all get this error message in MGCB :
Unexpected character encountered while parsing value: ´┐¢. Path '', line 0, position 0.
7> at Newtonsoft.Json.JsonTextReader.ParseValue()
7> at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
7> at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
7> at Newtonsoft.Json.Linq.JObject.Parse(String json)
7> at Ada2.Content.Pipeline.AsepriteSheet.AsepriteImporter.Import(String filename, ContentImporterContext context) in C:\Users\USERNAME\source\projects\Ada2\Ada2.Content\Pipeline\AsepriteSheet\AsepriteImporter.cs:line 22
7> at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/ContentImporter.cs:line 45
Any ideas if this is on my end or yours? I can give you a .aseprite file to test if needed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.