Click here to Skip to main content
15,918,889 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys ,

I am developing a card game using WPF and since i do not have any knowledge about animations i would like to know if someone could help me in how to write an animation to simulate a Card ( Image ) been played over a table.

At the bottom and top of my game table i have my cards on vertical position.
At the right and left my cards are on horizontal position.

What i really want is give an impression that a humman is selecting and throwing the card.

Many Thanks,
Marcelo
Posted

1 solution

This topic is too broad to describe in detail in one answer. You can learn animation starting from here: http://msdn.microsoft.com/en-us/library/ms752312.aspx[^].

Basically, the kind animation you need can be this: you add some graphical object and define some transformations (see below) and build the animation based on animation of the properties of the object itself and its transformation.

Some ideas:

You can either use fully-fledged 3D graphics or simulate 3D graphics using 2D graphics and graphics objects placed on the Canvas.

I can give you some arguments on favor of second approach: your 3D task is "almost 2D". You can represent a table and the cards as 2D objects "mangled" using simple affine transforms to simulation perspective and a look at different angles. Some elementary trigonometry and analytical algebra is needed in both approaches anyway. You will need to animate both object properties like their position on the Canvas, as well as the propertied of a transform, to show the rotation of the card.

In return to some limitation of this approach you can gain one powerful benefit: you can actually draw all your cards as vector graphic images in a vector editor, export them as XAML files you can include in your resource library. I would recommend using the wonderful Open-Source Inkscape editor, see:
http://en.wikipedia.org/wiki/Inkscape[^],
http://www.inkscape.org/[^].

Remember that this editor supports and is based on SVG (http://en.wikipedia.org/wiki/Scalable_Vector_Graphics[^], http://www.w3.org/Graphics/SVG/[^]), which has a set of feature superior to XAML, so you can only use a subset of SVG feature to be able to export graphics to XAML. However, even the set of features limited to XAML is amazingly good!

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900