WPF如何模拟纸牌 [英] WPF How to Simulate a Card been played

查看:62
本文介绍了WPF如何模拟纸牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用WPF开发纸牌游戏,由于我对动画没有任何了解,所以我想知道是否有人可以帮助我编写一张模拟纸牌(图像)的动画来在桌子上玩.

在游戏桌的底部和顶部,我的卡垂直放置.
我的卡片在左右两侧都处于水平位置.

我真正想要的是给人一种谦逊的印象,那就是选择并扔掉了卡片.

非常感谢,
Marcelo

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

推荐答案

该主题过于广泛,无法在一个答案中进行详细描述.您可以从此处开始学习动画: http://msdn.microsoft.com/en-us/library/ms752312.aspx [^ ].

基本上,您需要的那种动画可以是:添加一些图形对象并定义一些转换(请参见下文),然后基于对象本身的属性及其转换的动画来构建动画.

一些想法:

您可以使用成熟的3D图形,也可以使用2D图形和放置在Canvas上的图形对象来模拟3D图形.

我可以为您推荐第二种方法:您的3D任务是几乎2D".您可以使用简单的仿射变换到模拟透视图并查看不同角度,将桌子和卡片表示为2D对象.无论如何,这两种方法都需要一些基本的三角学和解析代数.您需要为两个对象属性设置动画,例如它们在画布"上的位置以及变换的属性,以显示卡的旋转.

作为这种方法的局限性,您可以获得一个强大的好处:您实际上可以在矢量编辑器中将所有卡绘制为矢量图形图像,将它们导出为可包含在资源库中的XAML文件.我建议使用出色的开源Inkscape编辑器,请参见:
http://en.wikipedia.org/wiki/Inkscape [ http://www.inkscape.org/ [ ^ ].

请记住,该编辑器支持并基于SVG( http://en.wikipedia.org/wiki/Scalable_Vector_Graphics [ ^ ],
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


这篇关于WPF如何模拟纸牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆