SpriteMaster Pro

 

Commands and Functions (in detail)


Command
SpriteGraphics
Parameters
width width of display
height height of display
depth Color depth (16,24,32)
viewmode 0=Windowed (debug) or fullscreen (non-debug)
1=Full Screen
2=Windowed
3=Windowed/scaled
pivotdistance Distance at which to place sprite pivot from camera.
Default value is 1.0
Increase if you get sprite flickering.
Description
Sets up the sprite display and special sprite pivot.

This command needs to be called BEFORE loading/creating sprites, loading packs, or displaying sprites.

Once this command is called you can use the following two global variables to access the sprite camera and sprite pivot used by SpriteMaster:

spritecamera - points to the 3D camera
spritepivot - points to a sprite pivot which all created/loaded sprites are attached to by default

Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
brick1=GetPackedSprite("brick1",pack)
PostionSprite brick1,200,100
RenderWorld : Flip : WaitKey
End
See also
EndSpriteGraphics
CreateSpritePivot()

-

 

Function
CreateSpritePivot()
Parameters
camera handle to main display camera
pivotdistance Distance at which to place sprite pivot from the camera.
Default value is 1.0 Increase if you get sprite flickering.
Description
Sets up sprite pivot for displaying the sprites.

Normally, this pivot is created by using the SpriteGraphics command. You can however use this function to create additional pivots to attach sprites to. Handy for hiding/showing a bunch of sprites simultaneously.

This function needs to be called BEFORE loading/creating sprites, or loading packs.

Example
Graphics3D 640,480
cam=CreateCamera()
piv=CreateSpritePivot(cam)
pack=LoadPack("bricks.png",0,piv)
See also
SpriteGraphics

-

Command
EndSpriteGraphics
Parameters
none
Description
Clears all entities, surfaces, textures, and brushes in existance then closes the graphics display. Also, does a complete cleanup of any internal data used by SpriteMaster.
Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
brick1=GetPackedSprite("brick1",pack)
PostionSprite brick1,200,100
RenderWorld : Flip : WaitKey
EndSpriteGraphics
See also
SpriteGraphics

-

Command
SpriteCameraZoom
Parameters
camera camera to zoom
zoomvalue# amount of zoom
Description
Zooms both the sprite camera and any sprite pivots simultaneously.
See
SpriteGraphics for more details on the sprite camera and CreateSpritePivot() for details regarding the sprite pivot.

NOTE: Only positive values can be used for zooming.

Example
SpriteGraphics 640,480
SpriteCameraZoom spritecamera,2.4
See also
SpriteGraphics

-

Function
CreateSprite()
Parameters
width width of sprite (in pixels)
height height of sprite (in pixels)
columns How many frames of animation in a column (default=1)
rows How many frames of animation in a row (default=1)
flags Flags for the sprites texture. Default is 32+16+4+1
See Blitz3D CreateTexture() for more details
parent parent to attach the sprite to.
Defaults to spritepivot as created by
SpriteGraphics or CreateSpritePivot()
Description
Creates a sprite with it's own mesh, texture, and surface inside a unique pack.

The sprites texture size is set to the next 'power of 2' value. Some examples here:

sprite.smSprite=CreateSprite(28,60) ; texture size will be 32x64
sprite.smSprite=CreateSprite(120,160) ; texture size will be 128x256

To set up animation frames for the sprite just supply values in the columns and rows parameters. Then, use the frame parameter in PositionSprite to show a particular frame in the sprite.

Example
create a sprite with a size of 28x30 which has 5 frames across and 4 frames down:

sprite.smSprite=CreateSprite(28,30,5,4)
PostionSprite sprite,40,70,7 ; show frame 7

The sprites default texture will be empty. Use SpriteTexture and GetSpriteTexture() to change this.

You can use GetPackedSprite() and CopySprite() with created sprites. Doing so makes the newly created sprite share the mesh in which the referenced sprite is using.

If you wish to find the new pack associated with the sprite then use the GetPack() function.

Example
SpriteGraphics 640,480
sprite.smSprite=CreateSprite(32,16)
PostionSprite sprite,100,50
RenderWorld : Flip : WaitKey
End
See also
PositionSprite , FreeSprite
GetPackedSprite() , CopySprite()
SpriteTexture , GetSpriteTexture() , GetSpriteMesh()
GetPack()

-

Function
LoadSprite()
Parameters
filename$ name of pack image to load
flags texture flags. Default is 32+16+4+1
See Blitz3D LoadTexture() for more details
parent parent to attach all extracted sprites (from the pack) to.
Defaults to spritepivot as created by
SpriteGraphics or CreateSpritePivot()
Description
Loads an image file and creates a new sprite.
The new sprite will have it's own mesh, texture, and surface inside a unique pack.

You should load images which have sizes using a 'power of 2' where possible. Otherwise the sprites image will appear blurred due to internal scaling of the texture.
Example width/height sizes are:

8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 , etc...

You can use GetPackedSprite() and CopySprite() with created sprites. Doing so makes the copied sprite share the pack/surface/mesh in which the referenced sprite is using.

If you wish to find the new pack associated with the sprite then use the GetPack() function.

Example
SpriteGraphics 640,480
ball.smSprite=LoadSprite("ball.png")
PositionSprite ball,100,100
See also
PositionSprite , FreeSprite
GetPackedSprite() , CopySprite() , GetPack()

-

Function
CreateTextSprite()
Parameters
filename$ name of font in pack
charoffset parent to attach the sprite to.
Defaults to spritepivot as created by
SpriteGraphics and CreateSpritePivot()
flags Flags for the sprites texture. Default is 32+16+4+1
See Blitz3D CreateTexture() for more details
Description
Creates a special text sprite with it's own mesh, texture, and surface inside a pack.

Text sprites are created by extracting an exsiting font image from within the specified pack. This font image needs to be set up using a particular sequence of characters.

Example:

! " # $ % & ( ) * +
, - . / 0 1 2 3 4 5
6 7 8 9 : ; < = > ?
@ A B C D E F G H I
J K L M N O P Q R S
T U V W X Y Z [ \ ]
^ _ ` a b c d e f g
h i j k l m n o p q
r s t u v w x y z {
| } ~              

The frame layout can be anything but the characters should use this string sequence (same as above):

!"#$%&()*+,-./0123456789
:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ
[/]^_`
abcedfghijklmnopqrstuvwxyz{|}~

Normally, using AddText, the first character in the font layout is a ! (exclamation mark). You can however use an charoffest parameter to tell SpriteMaster whereabouts the exclamation mark is. For example, your font layout might start with a SPACE followed by the exclamation mark. In which case you use an offset of 1:

mytext.smSprite=CreateTextSprite("textpack.png",1)

Use the animation settings in Image Packer to set up the appropriate frames for the font.

To add text/characters use AddText
To remove all text/characters use ClearText

If you wish to find the new pack associated with the text sprite then use the GetPack() function.

Example
SpriteGraphics 640,480
txt.smSprite=LoadFontSet("myfont.png")
PostionSprite txt,100,50
RenderWorld : Flip : WaitKey
End
See also
AddText , ClearText , GetPack()

-

Command
AddText
Parameters
sprite pointer to .smSprite instance
x x pos to display first character
y y pos to display first character
textstring$ string of characters to add
red red component of text being added
green green component of text being added
blue blue component of text being added
alpha alpha of text being added
Description
Adds a string of characters to an existing text sprite.
The x/y parameters specify the position to display the text.
You may supply optional color/alpha values to change the characters appearance.

A text sprite is a special kind of quad sprite set up to display a string of font characters. See the CreateTextSprite() function for details on how to set up a text sprite.

The textstring$ parameter can contain any valid character values.
There are a couple of control characters which can be passed to the
AddText command:

Chr$() Action
10 Start a new line
13 Start a new line

So, AddText txt,3,8,"Hello"+Chr$(10)+"World" produces:

Hello
World

NOTE2: There are a quite a few commands/functions which do not work with text sprites. Here is a list:

RotateSprite , ResizeSprite, FlipSprite , SetSprite ,
SpritesOverlap() , CopySprite()

Example
SpriteGraphics 640,480
txt.smSprite=CreateTextSprite("myfont.png")
AddText txt,20,40,"Hello World"
See also
CreateTextSprite() , ClearText

-

Command
ClearText
Parameters
sprite pointer to .smSprite instance
Description
Clears all characters/text displayed in a text sprite.
Refer to
CreateTextSprite() and AddText for details about text sprites.
Example
SpriteGraphics 640,480
txt=CreateTextSprite("fontpack.png")
AddText txt,10,10,"Hello"
ClearText txt
See also
CreateTextSprite() , AddText , ClearText

-

Command
FreeSprite
Parameters
sprite pointer to .smSprite instance
Description
Frees an existing sprite which has been created, loaded, copied, or extracted (from a pack).

You can see how many sprites are associated with a pack with the CountSpritesUsingPack() function.

If you have several hundred sprites in a surface you may wish to use this command outside of a loop.

Example
SpriteGraphics 640,480
ball.smSprite=LoadSprite("ball.png")
FreeSprite ball
See also
CreateSprite , LoadSprite() , CopySprite()
CreateTextSprite() , GetPackedSprite
FreePack

-

Function
LoadPack()
Parameters
filename$ name of pack to load
flags texture flags. Default is 32+16+4+1
See Blitz3D LoadTexture() for more details
Description
Loads a pack and returns an index number pointing to the pack.

The pack needs an associated *.def file to work correctly. See the Image Packer tool.

Once the pack is loaded you can extract as many sprites/images/textures as required using these functions:

GetPackedSprite()
GetPackedImage()
GetPackedTexture()

To free the pack (and associated sprites) use FreePack.

You can use CountPackedImages() to return the number of individual sprites/images in the pack. Alternatively, CountSpritesUsingPack() can be used to return the number of sprites using the pack.

Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
brick1.smSprite=GetPackedSprite("brick1",pack)
See also
GetPackedSprite() , GetPackedImage() , GetPackedTexture()
FreePack
CountSpritesUsingPack() , CountPackedImages()

-

Command
FreePack
Parameters
pack pack index to free
Description
Frees up an existing pack and any extracted/copied sprites belonging to the pack.

Sprites created or loaded with CreateSprite() / LoadSprite() have their own pack. If you use CopySprite() on these sprites then the copies will share the pack/surface. By using GetPack() to retrieve the pack you can then free up the original sprite as well as the copies by using via the FreePack command.

Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
brick1.smSprite=GetPackedSprite("brick1",pack)
FreePack pack

coin=LoadSprite("coin.png")
Dim c(5)
For n=1 to 5
c(n)=CopySprite(coin)
Next
coinpack=GetPack(coin)
FreePack coinpack ; free pack and coin/copies of coin

See also
LoadPack() , GetPackedSprite()
CopySprite() , FreeSprite , GetPack()

-

Function
GetPack()
Parameters
sprite pointer to .smSprite instance
Description
Returns the sprites associated pack. This is particularly handy for the CreateSprite() and LoadSprite() functions.
Having the pack details means you can use
FreePack to free up not only the pack, but also all sprites using the pack.
Handy for clearing up muliple copies etc ..
Example
coin=LoadSprite("coin.png")
Dim c(5)
For n=1 to 5
c(n)=CopySprite(coin)
Next
coinpack=GetPack(coin)
FreePack coinpack ; free pack and coin/copies of coin
See also
LoadSprite() , CreateSprite() , FreePack

-

Function
GetPackedSprite()
Parameters
ref$ name or index number of sprite in pack
pack which pack to extract sprite from
rX region - x offset
rY region - y offset
rW region - width
rH region - height
Description
Gets / extracts a sprite from a pack.
Using this function creates a new sprite by adding 4 vertices to a surface belonging to the pack. The sprite to get is determined by the ref$ value which can be used in 2 ways:

1) Sprites index number:
sprite.smSprite=GetPackedSprite(4,pack)
Gets the 4th sprite in the pack.
This is useful if you wish to extract all sprites into an array.
One thing to bear in mind is though, if you use Image Packer to modify the pack then the images in the pack are likely to be jumbled. This will cause the index numbers to refer to different images.
You can use
SpriteName$() to find the name of the sprite if using the index method.

2) Sprites name:
sprite.smSprite=GetPackedSprite("car",pack)
Gets the sprite called car from the pack. This name is set within Image Packer. The name is always lowercase and without spaces.

You can free up individually extracted sprites by using FreeSprite. Alternatively, use FreePack to clear ALL sprites associated with a pack (as well as the pack itself).

The optional rX,rY,rW,rH parameters are used to grab a region of the sprite image instead.
The rX and rY values are offsets from the top/left of the sprite image. rW and rH determine the width and height of the region.

Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
sprite3.smSprite=GetPackedSprite(3,pack)
boxsprite.smSprite=GetPackedSprite("box",pack)
clip.smSprite=GetPackedSprite("box",pack,8,4,10,10)
See also
FreeSprite , FreePack
CountSpritesUsingPack()
SpriteName$()
GetPackedImage() , GetPackedTexture()

-

Function
GetPackedImage()
Parameters
ref$ name or index number of image in pack
pack which pack to extract image from
Description
Gets / extracts a 2D image from a existing pack and returns the handle to the image.
The def$ value which can be used in 2 ways:

1) Images by index number:
myimage=GetPackedImage(4,pack)
Gets the 4th image in the pack.
This is useful if you wish to extract all images into an array.
One thing to bear in mind though, if you use Image Packer to modify the pack then the images in the pack are likely to be jumbled. This will cause the index numbers to refer to different images.

2) Images name:
image=GetPackedImage("car",pack)
Gets the image called car from the pack. This name is set within Image Packer. The name is always lowercase and without spaces.

Once you have your extracted the image the sprite pack can be freed up with FreePack.

Example
SpriteGraphics 640,480
pack=LoadPack("toys.png")
image=GetPackedImage("spinningtop",pack)
DrawImage image,60,70
See also
GetPackedSprite() , GetPackedTexture()
FreePack

-

Function
GetPackedTexture()
Parameters
ref$ name or index number of texture in pack
pack which pack to extract image from
Description
Creates a new texture by copying a packed image/sprites from an existing pack. The handle of the new texture is then returned.

The def$ value which can be used in 2 ways:

1) Textures by index number:
mytexture=GetPackedTexture(4,pack)
Gets the 4th texture in the pack.
This is useful if you wish to extract all textures into an array.
One thing to bear in mind though, if you use Image Packer to modify the pack then the textures in the pack are likely to be jumbled. This will cause the index numbers to refer to different textures.

2) Textures name:
mytexture=GetPackedTexture("brick",pack)
Gets the texture called brick from the pack. This name is set within Image Packer. The name is always lowercase and without spaces.

Once you have your extracted the texture the pack can be freed up with FreePack.

Example
SpriteGraphics 640,480
pack=LoadPack("toys.png")
image=GetPackedImage("spinningtop",pack)
DrawImage image,60,70
See also
GetPackedSprite() , GetPackedImage()
FreePack

-

Function
CountSpritesUsingPack()
Parameters
pack which pack to check
Description
Returns the number of sprites which are using a pack
Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
numimages=CountPackedImages(pack)

Dim s(100)
num=Rand(100)
For n=1 to num
s(n)=GetPackedSprite(Rand(1,numimages),pack)
Next

numsprites=CountSpritesUsingPack(pack)

See also
LoadPack() , GetPackedSprite() , CopySprite()

-

Function
CountPackedImages()
Parameters
pack pack to count images from
Description
Returns the number of sprites/images in a pack.
Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
num=CountPackedImages(pack)
See also
LoadPack()

-

Function
PackedImageName$()
Parameters
index index number of image in pack
pack which pack
Description
This function returns the name of an image in a pack.
The image is accessed via an index number.
The first image in a pack is index number 1.
The last image can be found by using
CountPackedImages() which returns the total number of images in a pack.
Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
num=CountPackedImages(pack)

For i=1 to num
DebugLog PackedImageName$(i,pack)
Next

See also
LoadPack() , CountPackedImages() , PackedImageFrames()

-

Function
PackedImageFrames()
Parameters
ref$ name or index number of sprite in pack
pack which pack to extract sprite from
Description
Returns the number of animation frames in a packed image/sprite from the specified pack.

If the image has no animation then a value of 1 is returned.

Example
SpriteGraphics 640,480
pack=LoadPack("spaceships.png")
DebugLog PackedImageFrames("ship1",pack)
See also
PackedImageName$()

-

Command
PositionSprite
Parameters
sprite pointer to .smSprite instance
x# x position (in pixels) on screen
y# y position (in pixels) on screen
frame optional frame number for animated sprites.
Description
Positions the sprite on screen at x,y pixel coordinates.
By default, the sprites top/left corner is used as an anchor point. Use
HandleSprite to change this.

If the optional frames parameter is used, the frame of the (animated) sprite is changed to the number supplied.

TIP: Unlike 2D images you do not need to call this every loop. Only when you wish to re-position the sprite.

Note: The 'frame' value supplied to PositionSprite automatically wraps around in both directions if the value is out of bounds. This helps to avoid incorrect animation frames being shown.

Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
character.smSprite=GetPackedSprite("runner",pack)
PostionSprite character,150,78,5 ; show frame number 5
See also
GetPackedSprite()
CreateSprite() , LoadSprite() , CopySprite()
LoadFontSet()
FreeSprite

-

Command
RotateSprite
Parameters
sprite pointer to .smSprite instance
angle# angle of rotation
movedistance# how far to move sprite in direction of angle
Description
Rotates a sprite by a given angle:
Angle Rotation
0/360 No rotation
90 Clockwise by 90 degrees
180 upside down
270 anti-clockwise by 90 degrees

The sprite is rotated around it's anchor point which can be changed with the HandleSprite command.

The optional movedistance# parameter can be used to move the sprite in the direction it is facing. You should design your sprites so that they face to the right by default.
Giving the movedistance# a negative value moves the sprite in the opposite direction.

Ommitting the angle# parameter rotates the sprite to its default orientation.

Example
SpriteGraphics 640,480
pack=LoadPack("vehicles.png")
car.smSprite=GetPackedSprite("car",pack)
PostionSprite car,200,100
RotateSprite car,42 ; rotate by 42 degrees.
See also
HandleSprite
ResetSprite

-

Function
CopySprite()
Parameters
sprite pointer to .smSprite instance
Description
Copies an existing sprite and returns an type instance pointing to the copy. The copied sprite shares the pack of the referenced sprite.

Unlike GetPackedSprite(), the CopySprite() function copies every attribute of the sprite including size, color, alpha, rotation, and flip status.

The new sprites name is the same as the copied sprite but with an underscore and new value appended.

Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
sprite.smSprite=GetPackedSprite("ball",pack)
newsprite.smSprite=CopySprite(sprite)
See also
GetPackedSprite()
FreeSprite

-

Command
ResizeSprite
Parameters
sprite pointer to .smSprite instance
width width in pixels
height height in pixels
Description
Resizes a sprite to new width/height pixel sizes.
If the width and height parameters are ommited the sprite is resized to it's default size.
Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
sprite.smSprite=GetPackedSprite("ball",pack)
ResizeSprite sprite,120,60 ; change size to 120 by 60 pixels.

NOTE: Resizing sprites causes them to blur. This is down the sprites texture being scaled and thereby losing the pixel<>texel match.

See also
ResetSprite

-

Command
FlipSprite
Parameters
sprite pointer to .smSprite instance
horizontally TRUE means flip sprite horizontally
vertically TRUE means flip sprite vertically
Description
Flips the sprite image horizontally and/or vertically.

If the horizontally and vertically parameters are omitted the sprites flip status is reset to default.

Example
SpriteGraphics 640,480
tree.smSprite=LoadSprite("trees.png")
FlipSprite tree,True ; flip the sprite horizontally
See also
ResetSprite

-

Command
HandleSprite
Parameters
sprite pointer to .smSprite instance
handleX# handle offset x
handleY# handle offset y
Description
Sets the axis/anchor/hotspot position of a sprite.

Postive values in handleX# and handleY# moves the hotspot right and down.
Negative values in handleX# and handleY# moves the hotspot left and up.

The hotspot is set by default to the top/left corner of a sprite which gives both handles a value of 0.

Ommiting the handleX# parameter centers handle horizontally.
Ommiting the handleY# parameter centers handle vertically.

Example
SpriteGraphics 640,480
pack=LoadPack("partyset.png")
sprite.smSprite=GetPackedSprite("baloon",pack)
HandleSprite sprite,16,2 ; move hotspot 16 across and 2 down
See also
ResetSprite

-

Command
SetSprite
Parameters
sprite pointer to .smSprite instance
x# x position (in pixels) on screen
y# y position (in pixels) on screen
frame optional frame number for animated sprites.
width width (in pixels)
height height (in pixels)
rotation amount of rotation
red red component color (0 to 255)
green green component color (0 to 255)
blue blue component color (0 to 255)
alpha transparency (0.0 to 1.0)
Description
Applies multiple settings to a sprite. Can save on having to use lots of calls to individual commands. Basically a 'one call does it all'.

With this command you can set the sprites frame, position, size, rotation, color, and alpha all within one call.

You can use 0 for the width/height which will leave the size of the sprite unchanged.

If you use negative values for red/green/blue/alpha then the current settings remain.

Example
SpriteGraphics 640,480
pack=LoadPack("toys.png")
ball.smSprite=GetPackedSprite("bigball",pack)
SetSprite ball,1,150,78,0,0,45,255,255,200,0.75
See also
PositionSprite , ResizeSprite , RotateSprite
SpriteColor , SpriteAlpha
ResetSprite

-

Command
ChangeSprite
Parameters
ref$ name or index number of sprite in pack
rX region - x offset
rY region - y offset
rW region - width
rH region - height
Description
Changes the image used by a sprite to another.
As an example you could change an animated spaceship into an animated explosion.

Changing the sprite image still keeps the axis/handle position relative to it's current setting. So, if the handle is centred it will remain so on the newly chosen image.

Also, if the current sprite is flipped horizontally and/or vertically this will also be applied to the new sprite image.

Note: You can only change the image to another from inside the pack used by the current sprite.

For a description of the ref$ parameter see GetPackedSprite()

The optional rX,rY,rW,rH parameters are used to grab a region of a sprite image instead.
The rX and rY values are offsets from the top/left of the sprite image. rW and rH determine the width and height of the region.

Example
SpriteGraphics 640,480
pack=LoadPack("bricks.png")
sprite3.smSprite=GetPackedSprite(3,pack)
boxsprite.smSprite=GetPackedSprite("box",pack)
clip.smSprite=GetPackedSprite("box",pack,8,4,10,10)
See also
GetPackedSprite()

-

Command
SpriteColor
Parameters
sprite pointer to .smSprite instance
red red color component (0 to 255)
green green color component (0 to 255)
blue blue color component (0 to 255)
alpha alpha value (0.0 to 1.0)
Description
Changes the sprites color and alpha settings.

If the red / green / blue / alpha parameters are ommitted then the sprite is reset to it's default values of white and opaque.

Example
SpriteGraphics 640,480
pack=LoadPack("balls.png")
sprite.smSprite=GetPackedSprite("ball01",pack)
SpriteColor sprite,10,50,30
See also
SpriteAlpha
ResetSprite

-

Command
SpriteAlpha
Parameters
sprite pointer to .smSprite instance
alpha alpha value (0.0 to 1.0)
Description
Changes the sprites alpha settings.

If the alpha parameter is ommitted then the sprite is reset to it's default alpha value of 1.0 (opaque).

Example
SpriteGraphics 640,480
pack=LoadPack("balls.png")
sprite.smSprite=GetPackedSprite("ball01",pack)
SpriteAlpha sprite,0.5 ; half transparent
See also
SpriteColor
ResetSprite

-

Command
ResetSprite
Parameters
sprite pointer to .smSprite instance
Description
Resets a sprite back to default. This includes size, rotation, flipped status, color, and alpha.
Example
SpriteGraphics 640,480
sprite.smSprite=LoadSprite("ball.png")
RotateSprite sprite,Rand(360)
ResizeSprite sprite,Rand(100),Rand(100)
SpriteColor sprite,Rand(255),Rand(255),Rand(255),Rnd(1)
ResetSprite sprite
See also
 

-

Function
SpritesOverlap()
Parameters
sprite1 pointer to .smSprite instance
sprite2 pointer to .smSprite instance
Description
Returns TRUE if 2 existing sprites are overlapping.
The function does not take the 'shape' of the sprite into account. Only the rectangular area used to display the sprite.
However, the function works fine with sprites which have been rotated, resized, and/or flipped.
Example
SpriteGraphics 640,480
pack=LoadPack("pack1.png")
sprite1.smSprite=GetPackedSprite("sun",pack)
sprite2.smSprite=GetPackedSprite("moon",pack)

PositionSprite sprite1,Rand(100),Rand(100)
PositionSprite sprite2,Rand(100),Rand(100)

DebugLog SpritesCollide(sprite1,sprite2)

See also
 

-

Function
GetSpriteMesh()
Parameters
sprite pointer to .smSprite instance
Description
Returns the mesh used by the sprite
Example
SpriteGraphics 640,480
pack=LoadPack("pack1.png")
sprite.smSprite=GetPackedSprite("sun",pack)
mesh=GetSpriteMesh(sprite)
See also
GetSpriteTexture()

-

Command
SpriteTexture
Parameters
sprite pointer to .smSprite instance
texture Handle to an existing texture
Description
Changes the texture used by a sprite.

Note: This will affect any sprites sharing the texture such as those created with:

CopySprite()
GetPackedSprite()

Example
sprite.smSprite=CreateSprite(64,80)
texture=LoadTexture("tree.png")
SpriteTexture sprite,texture
See also
GetSpriteTexture() , GetPackedTexture()

-

Function
GetSpriteTexture()
Parameters
sprite pointer to .smSprite instance
Description
Returns the handle of the texture used by the sprite
Example
sprite.smSprite=LoadSprite("sun.png")
texture=GetSpriteTexture(sprite)
See also
SpriteTexture , GetPackedTexture()

Main Page