Files
RCBASIC4/doc/files/setspritesource.txt
2024-12-11 14:14:00 -07:00

43 lines
933 B
Plaintext

#title SetSpriteSource [RCBasic Doc]
#header Sub SetSpriteSource(sprite, img)
Changes the image source for a sprite frame sheet
Note: This needs to be the same size as the current image source or you will have rendering issues
#code
isFullScreen = false
vSync = true
winWidth = 640
winHeight = 480
canViewPortX = 0
canViewPortY = 0
OpenWindow("SetSpriteSource", winWidth, winHeight, isFullScreen, vSync)
sCanvas = OpenCanvasSpriteLayer(canViewPortX, canViewPortY, winWidth, winHeight)
Canvas(sCanvas)
DIM frown
DIM frownW
DIM frownH
frowny1 = LoadImage("frowny1.png")
frowny2 = LoadImage("frowny2.png")
GetImageSize(frown, frownW, frownH)
frownSprite = CreateSprite(frown, frownW, frownH)
SetSpritePosition(frownSprite, 100, 100)
While Not Key(K_ESCAPE)
If KEY(K_SPACE) Then
SetSpriteSource(frownSprite, frowny2)
End If
Update()
Wend
#/code
#image "images/frowny1.png"
#image "images/frowny2.png"
#ref GetSpriteSource