I'm very new to coding overall, in face I just started. But what i'm trying to do is use an animated sprite for when the sprite moves and go back to a still image when there isn't any imput. I've achieved this but I put both sprites on top of each other just changing their alpha's so you don't see the still when you're moving your player, and vice versa for when its still.
I tried setting the position of the opposing sprite off the screen and bringing it back in but I didn't have any luck if anybody has any tips or ideas it would be greatly appreciated!
-THANKS IN ADVANCE
This is my code
SetWindowTitle( "animating from a sprite sheet." )
SetWindowSize( 1920, 1080, 0 )
// Screen
SetVirtualResolution( 1920, 1080 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetWindowAllowResize(1)
print (Screenfps())
//Animation
Astronaut=loadimage("Astronaut.png")
CreateSprite(2,Astronaut)
SetSpritePosition(2,2000,1100)
SetSpriteAnimation(2,64,64,6)
//Screen controll Make the sprite not go off the screen
//If X#>GetVirtualWidth()-GetSpriteWidth(2) <-------------- I tried to make it so my sprites wouldn't be able to go off the screen, didn't work so I commented it out
// X#= GetVirtualWidth() -GetSpriteWidth(2)
//Endif
//images and basic position
loadimage(2,"still.png")
CreateSprite(1,2)
SetSpritePosition(1,960,540)
do
x# = GetSpriteX(1)
y# = GetSpriteY(1)
//Physics
//SetSpritePHysicsOn(2,2)
//SetSpritePhysicsOn(1,2) <-------------- the physics of both sprites collide with each other so I commented them out
SetPhysicsWallBottom(1)
SetPhysicsWallTop(1)
SetPhysicsWallLeft(1)
SetPhysicsWallRight(1)
// A KEY
If GetRawKeyState(68)
SetSpritePosition ( 2 , GetSpriteX ( 1 ) + 3 , GetSpriteY ( 1 ) + 0 )
SetSpritePosition ( 1 , GetSpriteX ( 1 ) + 3 , GetspriteY ( 1 ) + 0 )
setspriteflip(2,0,0)
SetSpriteColorAlpha(1,0)
Endif
If GetRawKeyPressed(68)
playsprite(2)
SetspritecolorAlpha(2,255)
Endif
If GetRawKeyReleased(68)
setspritecoloralpha(2,0)
setspritecoloralpha(1,255)
Endif
// D KEY
If getRawKeyState(65)
setspriteflip(2,1,0)
SetSpritePosition ( 2 , GetSpritex ( 1 ) -3 , GetSpritey ( 1 ) + 0 )
setspritePosition ( 1 , GetSpriteX ( 1 ) -3 , GetSpriteY ( 1 ) + 0 )
SetSpriteColorAlpha(1,0)
Endif
If GetRawKeyPressed(65)
playsprite(2)
SetSpriteColorAlpha(2,255)
Endif
if GetRawKeyReleased(65)
SetSpriteColorAlpha(2,0)
SetSpriteColorAlpha(1,255)
Endif
sync()
loop