Compare commits
No commits in common. "b15a55afd1b1741a0c723385ea7ae88d05d47ebd" and "7ed2f3ebb66bdb81c58e1ec18afc2efffaa15a01" have entirely different histories.
b15a55afd1
...
7ed2f3ebb6
@ -27,7 +27,6 @@
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="System.Text.Json" Version="5.0.2" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
|
||||
</Project>
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace SemiColinGames {
|
||||
public static class Sprites {
|
||||
@ -61,32 +61,29 @@ namespace SemiColinGames {
|
||||
Texture = texture;
|
||||
animations = new Dictionary<string, SpriteAnimation>();
|
||||
|
||||
JsonElement jsonRoot = JsonDocument.Parse(metadataJson).RootElement;
|
||||
JObject json = JObject.Parse(metadataJson);
|
||||
|
||||
frames = new List<Frame>();
|
||||
foreach (JsonElement child in jsonRoot.GetProperty("frames").EnumerateArray()) {
|
||||
JsonElement frame = child.GetProperty("frame");
|
||||
foreach (JToken child in json.SelectToken("frames").Children()) {
|
||||
Rectangle source = new Rectangle(
|
||||
frame.GetProperty("x").GetInt32(),
|
||||
frame.GetProperty("y").GetInt32(),
|
||||
frame.GetProperty("w").GetInt32(),
|
||||
frame.GetProperty("h").GetInt32());
|
||||
|
||||
double duration = child.GetProperty("duration").GetDouble() / 1000;
|
||||
child.SelectToken("frame.x").Value<int>(),
|
||||
child.SelectToken("frame.y").Value<int>(),
|
||||
child.SelectToken("frame.w").Value<int>(),
|
||||
child.SelectToken("frame.h").Value<int>());
|
||||
double duration = child.SelectToken("duration").Value<double>() / 1000;
|
||||
frames.Add(new Frame(source, duration));
|
||||
}
|
||||
|
||||
// We assume that all frames are the same size (which right now is assured by the
|
||||
// Aseprite-based spritesheet export process).
|
||||
Width = frames[0].Source.Width;
|
||||
Height = frames[0].Source.Height;
|
||||
|
||||
JsonElement frameTags = jsonRoot.GetProperty("meta").GetProperty("frameTags");
|
||||
foreach (JsonElement child in frameTags.EnumerateArray()) {
|
||||
string name = child.GetProperty("name").GetString();
|
||||
int start = child.GetProperty("from").GetInt32();
|
||||
int end = child.GetProperty("to").GetInt32();
|
||||
string directionString = child.GetProperty("direction").GetString();
|
||||
JToken frameTags = json.SelectToken("meta.frameTags");
|
||||
foreach (JToken child in frameTags.Children()) {
|
||||
string name = child.SelectToken("name").Value<string>();
|
||||
int start = child.SelectToken("from").Value<int>();
|
||||
int end = child.SelectToken("to").Value<int>();
|
||||
string directionString = child.SelectToken("direction").Value<string>();
|
||||
AnimationDirection direction = directionString == "pingpong" ?
|
||||
AnimationDirection.PingPong : AnimationDirection.Forward;
|
||||
double duration = 0;
|
||||
|
@ -179,19 +179,18 @@
|
||||
<PackageReference Include="SharpDX.XAudio2">
|
||||
<Version>4.2.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Text.Json">
|
||||
<Version>5.0.2</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Framework.WindowsUniversal" Version="3.8.0.*" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
Loading…
Reference in New Issue
Block a user