游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3790|回复: 9

用DX8如何在画文字时只画文字的一部分

[复制链接]

87

主题

790

帖子

806

积分

高级会员

Rank: 4

积分
806
QQ
发表于 2007-12-22 11:17:00 | 显示全部楼层 |阅读模式
就是像在屏幕边角那样,只画在屏幕范围内的。我现在是要在屏幕的任意位置都只显示画出的文字的一部分。

87

主题

790

帖子

806

积分

高级会员

Rank: 4

积分
806
QQ
 楼主| 发表于 2007-12-30 17:56:00 | 显示全部楼层

Re:用DX8如何在画文字时只画文字的一部分

问题解决了:
Public Type POINTAPI
x As Long
y As Long
End Type
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public getpos As POINTAPI
Public DX As DirectX8
Public D3D As Direct3D8
Public D3DDevice As Direct3DDevice8
Public d3dx As D3DX8
Public Sprite As D3DXSprite
Public Running As Boolean

Public Tex As Direct3DTexture8
Public TexSurbf As Direct3DSurface8
Public nColorKey As Long
Public Rect1 As RECT
Public Scal As D3DVECTOR2
Public Rotation As Single
Public Center As D3DVECTOR2
Public Tran As D3DVECTOR2
Public Color As Long

Public DI As DirectInput8
Public DIDEV As DirectInputDevice8
Public DIDEV1 As DirectInputDevice8
Public DIState As DIKEYBOARDSTATE
Public DIMouse As DIMOUSESTATE
Public mousex As Single, mousey As Single

Public DXFont As D3DXFont
Public mlngTimer As Long
Public mlngFrameTimer As Long
Public mintFPS As Long
Public mintFPSCounter As Long

Public TexDesc(1)      As D3DXIMAGE_INFO
Public useTexDesc(1)      As D3DXIMAGE_INFO

Sub main()
Running = True

Set DX = New DirectX8
Set D3D = DX.Direct3DCreate

Dim Dpp1 As D3DPRESENT_PARAMETERS
Dpp1.SwapEffect = D3DSWAPEFFECT_DISCARD
Dpp1.BackBufferWidth = 800
Dpp1.BackBufferHeight = 600
Dpp1.BackBufferFormat = D3DFMT_A8R8G8B8

Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Form1.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, Dpp1)

Set d3dx = New D3DX8
Set Sprite = d3dx.CreateSprite(D3DDevice)

Set DI = DX.DirectInputCreate()
Set DIDEV = DI.CreateDevice("GUID_SysKeyboard")
DIDEV.SetCommonDataFormat DIFORMAT_KEYBOARD
DIDEV.SetCooperativeLevel Form1.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE
DIDEV.Acquire
Set DIDEV1 = DI.CreateDevice("GUID_SysMouse")
DIDEV1.SetCommonDataFormat DIFORMAT_MOUSE
DIDEV1.SetCooperativeLevel Form1.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE
DIDEV1.Acquire

Set Tex = d3dx.CreateTexture(D3DDevice, 200, 200, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT)
Set TexSurbf = D3DDevice.GetRenderTarget

Dim m_vbFont As IFont
Dim x As New StdFont
x.Name = "宋体"
x.Bold = False
x.Italic = False
x.Underline = False
x.Size = 20


Set m_vbFont = x
Set DXFont = d3dx.CreateFont(D3DDevice, m_vbFont.hFont)
Do While Running = True
DIDEV.GetDeviceStateKeyboard DIState
If DIState.Key(DIK_ESCAPE) Then End
DIDEV1.GetDeviceStateMouse DIMouse
If DIMouse.Buttons(0) And DIMouse.Buttons(1) Then End

mlngTimer = GetTickCount()
If GetTickCount() - mlngFrameTimer >= 1000 Then
    mintFPS = mintFPSCounter + 1
    mintFPSCounter = 0
    mlngFrameTimer = GetTickCount()
Else
    mintFPSCounter = mintFPSCounter + 1
End If

D3DDevice.SetRenderTarget Tex.GetSurfaceLevel(0), Nothing, ByVal 0

D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, 0, 0, 0
D3DDevice.BeginScene

Rect1.Left = 190
Rect1.Top = 190
Rect1.Right = 300
Rect1.bottom = 300
d3dx.DrawText DXFont, D3DColorRGBA(255, 255, 255, 255), mintFPS, Rect1, 0
D3DDevice.EndScene

D3DDevice.SetRenderTarget TexSurbf, Nothing, ByVal 0
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, 0, 0, 0
D3DDevice.BeginScene
Sprite.Begin
Tran.x = 100
Tran.y = 100
Rect1.Left = 0
Rect1.Right = 200
Rect1.Top = 0
Rect1.bottom = 200

Scal.x = 1
Scal.y = 1
Center.x = 0
Center.y = 0
Rotation = 0
Color = D3DColorRGBA(255, 255, 255, 255)
Sprite.Draw Tex, Rect1, Scal, Center, Rotation, Tran, Color
Sprite.End
D3DDevice.EndScene

D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
DoEvents
Loop

End Sub

61

主题

1429

帖子

1430

积分

金牌会员

Rank: 6Rank: 6

积分
1430
发表于 2008-1-1 15:24:00 | 显示全部楼层

Re:用DX8如何在画文字时只画文字的一部分

画张图也要这么变量??

187

主题

6490

帖子

6491

积分

论坛元老

团长

Rank: 8Rank: 8

积分
6491
发表于 2008-1-1 18:13:00 | 显示全部楼层

Re:用DX8如何在画文字时只画文字的一部分

画了再用其他东西覆盖嘛?

187

主题

6490

帖子

6491

积分

论坛元老

团长

Rank: 8Rank: 8

积分
6491
发表于 2008-1-1 18:14:00 | 显示全部楼层

Re: Re:用DX8如何在画文字时只画文字的一部分

使命召唤: Re:用DX8如何在画文字时只画文字的一部分

画张图也要这么变量??

哪像您游戏之家,拖个Label控件或者设置一下模型坐标就可以了哦~~~~是吧??

61

主题

1429

帖子

1430

积分

金牌会员

Rank: 6Rank: 6

积分
1430
发表于 2008-1-1 22:57:00 | 显示全部楼层

Re: Re: Re:用DX8如何在画文字时只画文字的一部分

Miu.C: Re: Re:用DX8如何在画文字时只画文字的一部分


哪像您游戏之家,拖个Label控件或者设置一下模型坐标就可以了哦~~~~是吧??


你在说你的RPG吧? 你的游戏肯定是不用坐标的, 佩服!

187

主题

6490

帖子

6491

积分

论坛元老

团长

Rank: 8Rank: 8

积分
6491
发表于 2008-1-5 17:59:00 | 显示全部楼层

Re: Re: Re: Re:用DX8如何在画文字时只画文字的一部分

使命召唤: Re: Re: Re:用DX8如何在画文字时只画文字的一部分



你在说你的RPG吧? 你的游戏肯定是不用坐标的, 佩服!

啊,不愧是游戏之家,真聪明~~~

15

主题

202

帖子

207

积分

中级会员

Rank: 3Rank: 3

积分
207
QQ
发表于 2008-1-5 21:59:00 | 显示全部楼层

Re:用DX8如何在画文字时只画文字的一部分

模板测试?

29

主题

475

帖子

483

积分

中级会员

Rank: 3Rank: 3

积分
483
发表于 2008-2-15 01:49:00 | 显示全部楼层

Re: Re: Re: Re: Re: Re: Re:用DX8如何在画文字时只画文字的一部分

Miu.C: Re: Re: Re: Re: Re: Re:用DX8如何在画文字时只画文字的一部分


マスダ??、来年もよろしくね~~



意味を知りません。

1

主题

57

帖子

59

积分

注册会员

Rank: 2

积分
59
QQ
发表于 2008-2-16 10:30:00 | 显示全部楼层

Re: Re: Re: Re: Re: Re: Re: Re:用DX8如何在画文字时只画文字的

大元帅: Re: Re: Re: Re: Re: Re: Re:用DX8如何在画文字时只画文字的一部分




意味を知りません。

中文:"大师",新的一年也"多多指教"
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-20 01:16

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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