Skip to content

Commit

Permalink
Merge pull request craftworkgames#837 from craftworkgames/tweener_enc…
Browse files Browse the repository at this point in the history
…hancing3

Tweener enchancing3
  • Loading branch information
Gandifil authored Jan 22, 2024
2 parents c4f9b3c + 79a2070 commit 6acc822
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
8 changes: 8 additions & 0 deletions MonoGame.Extended.Tweening.Tests/ColorHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Microsoft.Xna.Framework;

namespace MonoGame.Extended.Tweening.Tests;

public class ColorHandler
{
public Color Color { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0"/>
<PackageReference Include="xunit" Version="2.4.1"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\cs\MonoGame.Extended.Tweening\MonoGame.Extended.Tweening.csproj" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions MonoGame.Extended.Tweening.Tests/TweenerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Xna.Framework;
using Xunit;

namespace MonoGame.Extended.Tweening.Tests;

public class TweenerTests
{
[Fact]
public void TweenerTweenToSuccessTest()
{
var tweener = new Tweener();
var obj = new ColorHandler();
tweener.TweenTo(obj, x => x.Color, Color.Red, 2f);
}
}
11 changes: 11 additions & 0 deletions MonoGame.Extended.sln
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Benchmarks.Collisions", "MonoGame.Extended.Benchmarks.Collisions\MonoGame.Extended.Benchmarks.Collisions.csproj", "{6B5939ED-E99D-4842-B4FE-A7624C59A60A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Tweening.Tests", "MonoGame.Extended.Tweening.Tests\MonoGame.Extended.Tweening.Tests.csproj", "{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -199,6 +201,14 @@ Global
{6B5939ED-E99D-4842-B4FE-A7624C59A60A}.Release|Any CPU.Build.0 = Release|Any CPU
{6B5939ED-E99D-4842-B4FE-A7624C59A60A}.Release|x86.ActiveCfg = Release|Any CPU
{6B5939ED-E99D-4842-B4FE-A7624C59A60A}.Release|x86.Build.0 = Release|Any CPU
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}.Debug|x86.ActiveCfg = Debug|Any CPU
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}.Debug|x86.Build.0 = Debug|Any CPU
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}.Release|Any CPU.Build.0 = Release|Any CPU
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}.Release|x86.ActiveCfg = Release|Any CPU
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -212,6 +222,7 @@ Global
{34841DEB-EEC0-477C-B19D-CBB6DF49ED39} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
{CB439E84-F0F6-4790-8CD1-8A66C3D7B4DA} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
{6B5939ED-E99D-4842-B4FE-A7624C59A60A} = {AAB81CB9-9C71-4499-A51E-933C384D6DBF}
{A1BD6FDC-5A76-4D14-8FDA-ACD153C8EBCC} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8ED5A62D-25EC-4331-9F99-BDD1E10C02A0}
Expand Down
4 changes: 3 additions & 1 deletion src/cs/MonoGame.Extended.Tweening/Tweener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public Tween<TMember> TweenTo<TTarget, TMember, TTween>(TTarget target, Expressi
activeTween?.Cancel();

AllocationCount++;
var tween = (TTween)Activator.CreateInstance(typeof(TTween), BindingFlags.Public | BindingFlags.NonPublic, null, new object?[]{target, duration, delay, member, toValue});
var tween = (TTween)Activator.CreateInstance(typeof(TTween),
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null,
new object?[]{target, duration, delay, member, toValue}, null);
_activeTweens.Add(tween);
return tween;
}
Expand Down

0 comments on commit 6acc822

Please sign in to comment.