游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2343|回复: 1

向各位请教,有2张图,想把它们重叠在一起显示。

[复制链接]

3

主题

6

帖子

6

积分

新手上路

Rank: 1

积分
6
发表于 2006-6-10 21:12:00 | 显示全部楼层 |阅读模式
有2张图,想把它们重叠在一起显示。
当然下面的图要大一点显示。
我的问题是,如何来实现重叠显示呢?

下面是一部分程序,各位给出个主意好吗?先谢了。

1.定义部分
// 纹理
private Texture imageTexture = null;
// 图形文件名
private string imageFileName = "xxx.png";
// 大小
private Size imageSize;

2.纹理生成处理部分
ImageInformation imageInfo = new ImageInformation();

// 生成纹理
this.imageTexture = TextureLoader.FromFile( this.device,
                                            this.imageFileName,
                                            0,
                                            0,
                                            1,
                                            0,
                                            Format.A8R8G8B8,
                                            Pool.Managed,
                                            Filter.None,
                                            Filter.None,
                                            0,
                                            ref imageInfo);
// 大小设定
this.imageSize = new Size(imageInfo.Width, imageInfo.Height);



3.纹理显示部分

Matrix scale = new Matrix();
scale.Scale(1.0f, 1.0f, 0.0f);

Matrix preScale = this.sprite.Transform;
this.sprite.Transform = scale;

Rectangle drawRect = new Rectangle( 100, 100, 300, 300);
this.sprite.Draw( this.imageTexture,
                  Rectangle.Empty,
                  new Vector3(0.0f, 0.0f, 0.0f),
                  new Vector3((float)drawRect.X / scale.M11, (float)drawRect.Y / scale.M22, 0.0f),
                  Color.FromArgb(255, 255, 255, 255)
);

this.sprite.Transform = preScale;

3

主题

6

帖子

6

积分

新手上路

Rank: 1

积分
6
 楼主| 发表于 2006-6-15 17:09:00 | 显示全部楼层

已解决!方法是再同样做一个纹理显示即可!

XieXie
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-24 19:20

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表