Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swapping Sprites

Status
Not open for further replies.

Butters261285

Programmer
Jan 2, 2006
29
GB
I am in the progress of making a scrollin space shooter, i have managed to get all of the coding to work so that it moves, the screen has boundaries, the ship can fire two lasers that add to a score when they hit the aliens. Ive got some fake AI settings on the aliens so they appear at different places when they die (me.spriteNum).loch=random(30)or something similar.

i have made an image in photoshop of the ship on a slant left and right, all i require to know now is what the code is to swap a sprite with another image while a key is being pressed.

i would imagine somehting like

if keypressed(125) then
sprite(me.spriteNum) = sprite(4)
end if

if keyreleased(125) then
sprite(4) = sprite(me.spriteNum)
end if

but im not sure, can anyone help ?
 
this is what you have to do..

You need an additional information
orgSprite
and let
sprite(me.spriteNum).value change not change the sprite!

property orgSprite

if keypressed(125) then
orgSprite = sprite(me.spriteNum)
sprite(me.spriteNum) = sprite(4)
end if

if keyreleased(125) then
sprite(me.spriteNum) = orgSprite
end if


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Bill Ang, Lead Programmer
Programming the Future
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top