LoadSprite ( file$[,texture_flags][,parent] )
Parameters
|
file$ - image file to use as the sprite texture texture_flags (optional) - texture flags, as per LoadTexture; 1 (default): 1: colour 2: alpha 4: masked - areas coloured 0,0,0 are not drawn 8: mipmapped 16: clamp u - no horizontal tiling 32: clamp v - no vertical tiling 64: spherical environment map parent (optional) - entity to parent the sprite to; 0 (default) for none |
Description
|
Creates a sprite and puts a texture on it in one step, returning the sprite handle. It is exactly CreateSprite followed by LoadTexture and EntityTexture, which is what most sprites need anyway. The sprite starts at 0,0,0, spans -1,-1 to +1,+1 and faces the camera. The flags are worth thinking about. Flag 2 gives soft alpha edges - the right choice for smoke, glows and anything with a feathered outline - while flag 4 is the cheaper cut-out where pure black vanishes, which suits crisp art like leaves and sparks. Flag 3 (1+2) is the common combination for effect art with an alpha channel. Remember that active texture filters add their flags on top, so mipmapping usually arrives whether you asked for it or not. For glowing effects, pair the sprite with EntityBlend sprite,3 so black areas disappear and bright ones add light into the scene. As with any texture load, check the returned handle before using it, and use the sprite commands - ScaleSprite, RotateSprite, HandleSprite, SpriteViewMode - rather than the entity mesh commands. See also: CreateSprite, SpriteViewMode, ScaleSprite, HandleSprite, LoadTexture, EntityBlend. |
Example
; LoadSprite Example ; ------------------ Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ground=CreatePlane() EntityTexture ground,LoadTexture("media/MossyGround.BMP") ; LoadSprite creates a sprite and textures it in one call - here a ; floating logo pickup for our game world logo=LoadSprite("media/b3dlogo.jpg") ScaleSprite logo,1,0.5 PositionEntity logo,0,1.5,0 bob#=0 While Not KeyDown(1) ; Bob the pickup up and down so the scene feels alive bob=bob+2 PositionEntity logo,0,1.5+Sin(bob)*0.3,0 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrows: move camera Esc: exit" Text 0,20,"LoadSprite loaded a textured sprite - orbit it: it always faces you" Flip Wend End
Index