怎样站一张扑克牌画得快一些?

wyj 2000-01-04 04:50:00
我做了一个扑克牌的游戏,关于画牌的部分用了一个笨办法。先定义一个TCard对象,主要有BmpId和PaintBox属性,分别指明这张牌面的图案在图象表中的索引和显示这张牌需要用的PaintBox。这样我一共建立了54个TCard实例,在游戏中指挥这些PaingBox在屏幕上跑来跑去,由于牌面的图案不是正矩形,它的四个角是圆的,所以在这些PaintBox对象的OnDraw事件中这样写道:(每张牌的尺寸是71*96,每个BMP的尺寸是69*94,每个BMP的四个顶点是黑色点)
(1)先Draw(1,1,BmpList[BmpId]);//画牌面中心的图案
(2)再画四条黑色边框线,但四个角不顶满,每条线的端点距离顶点2个象素。
这样画出来的牌比较好看,而且四个圆角是透明的。
但是游戏完成后感觉画牌的速度比较慢,如果把各PaintBox的ControlStyle属性中加上[csOpaque],速度稍快一点,但由于不刷新背景,四个角不再是透明的了,很难看。怎么办 ?是不是有更好的方法?(本来想给100分,但分不够用了,只好省着点儿,各位大侠吃点亏吧)
...全文
768 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wyj1 2000-01-04
  • 打赏
  • 举报
回复
谢谢老虎哥,果然速度快了一些,但是还是达不到红心大战的速度,有没有其它办法呢?
tiger 2000-01-04
  • 打赏
  • 举报
回复
如果是TBitMap的话, 要这样:
BitBlt(PaintBox.Canvas.Handle, 0, 0, 100, 100,
BmpList[BmpId].Canvas.Handle, 0, 0, SRCCOPY)
tiger 2000-01-04
  • 打赏
  • 举报
回复
肯定是能出来的, 你的BmpList是Tbitmap吗?
看看BitBlt的定义吧.
BOOL BitBlt(

HDC hdcDest, // handle to destination device context
int nXDest, // x-coordinate of destination rectangle's upper-left corner
int nYDest, // y-coordinate of destination rectangle's upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source device context
int nXSrc, // x-coordinate of source rectangle's upper-left corner
int nYSrc, // y-coordinate of source rectangle's upper-left corner
DWORD dwRop // raster operation code
);
wyj 2000-01-04
  • 打赏
  • 举报
回复
十分感谢老虎哥:我把您的BITBLT粘贴进去以后出来的只有边框线了,好象中心的图案根本没有画出来,怎么回事?
wyj 2000-01-04
  • 打赏
  • 举报
回复
本人回复:好感激ZDG大哥。Cards.dll怎么用?有源码示例吗?
tiger 2000-01-04
  • 打赏
  • 举报
回复
把Draw(1,1, BmpList[BmpId])用bitblt替换吧
BitBlt(PaintBox.Canvas.Handle, 0, 0, 100, 100, BmpList[BmpId].Handle,
0, 0, SRCCOPY)
zdg 2000-01-04
  • 打赏
  • 举报
回复
windows本身有一个cards.dll很多人在用, 你为什么不用呢???

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧