Microsoft DirectX 8.1 (Visual Basic)

D3DXSprite.Draw

Draws a simple sprite in screen-space.

object.Draw( _ 
    SrcTexture As Direct3DTexture8, _ 
    SrcRect As Any, _ 
    Scaling As D3DVECTOR2, _ 
    RotationCenter As D3DVECTOR2, _ 
    Rotation As Single, _ 
    Translation As D3DVECTOR2, _ 
    Color As Long)

Parts

object
Object expression that resolves to a D3DXSprite object.
SrcTexture
A Direct3DTexture8 object, representing the source image used for the sprite.
SrcRect
A RECT type that indicates what portion of the source texture to use for the sprite. If this parameter is ByVal 0, then the entire source image is used for the sprite. However, you can specify a sub-rectangle of the source image instead.

Before transformation, the size of the sprite is defined by SrcRect with the top-left corner at the origin (0,0).

Scaling
A D3DVECTOR2 type, containing the scaling vector. If this argument is ByVal 0, the value (1.0, 1.0) is used. Since Scaling is a vector, a multiplier of 1.0 would preserve the source size.
RotationCenter
A D3DVECTOR2 type, containing the point that in screen pixels that identifies the center of rotation. If this argument is ByVal 0, the point (0,0) is used, which is the upper-left corner of the texture.
Rotation
Value that specifies the rotation in radians, counter-clockwise.
Translation
[in] Pointer to a D3DVECTOR2 type, containing the translation in screen pixels. If this argument is ByVal 0, the point (0,0) is used.
Color
The color and alpha channels are modulated by this value. A value of &HFFFFFFFF& maintains the original source color and alpha data.

Error Codes

If the method fails, an error is raised and Err.Number can be set to D3DERR_INVALIDCALL.

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

This method must be called between an Direct3DDevice8.BeginScene and Direct3DDevice8.EndScene pair.

If D3DXSprite.Begin has not been called, this method internally calls Begin and D3DXSprite.End. When making successive calls to D3DXSprite.Draw and/or D3DXSprite.DrawTransform, make sure to call Begin to avoid the extra overhead of Draw and DrawTransform internally calling Begin and End each time.

The image can be mirrored by specifying a negative vector in the appropriate direction (x, y, or both) for the Scaling parameter and adding the width and/or height of the source rectangle, specified in the SrcRect parameter, to the values specified in the Translation parameter. Note that this will change the point of origin for rotations.

See Also

D3DXSprite.DrawTransform