Created
August 5, 2012 19:26
-
-
Save demonixis/3266800 to your computer and use it in GitHub Desktop.
Expression Lambda with C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void AddExplosion(int x, int y) | |
{ | |
Sprite explode = new Sprite("SFX/explosion2"); | |
explode.LoadContent(); | |
explode.Position = new Vector2(x, y); | |
explode.PrepareAnimation(94, 94); | |
explode.AddAnimation("0", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, 25, false); | |
// Expression Lambda | |
// equivalent à explode.GetAnimation("0").AnimationComplete += onAnimationComplete; | |
// et ensuite déclaration d'une fonction de callback public void onAnimationComplete(object sender, EventArgs e) { } | |
explode.GetAnimation("0").AnimationComplete += (sender, e) => | |
{ | |
explode.Kill(); | |
_recycled.Add(Members.IndexOf(explode)); | |
}; | |
Add(explode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment