Post new topic    
Liquid Metal Slime
Send private message
Sprite Scripting Woes 
 PostWed Jan 20, 2010 5:48 pm
Send private message Reply with quote
For some reason, sprites called by scripting don't seem to be moving to the location I want them to. Instead, they just sit in the top left corner, regardless of what coordinates I put in for them. What could I be doing wrong?

Code:
   if (lives == 1) then (
   livesbar:= load medium enemy sprite (3)
   place sprite (livesbar,9,9)
   )
   if (lives == 2) then (
   livesbar:= load medium enemy sprite (2)
   place sprite (livesbar,9,9)
   )
   if (lives == 3) then (
   livesbar:= load medium enemy sprite (1)
   place sprite (livesbar,9,9)
   )

Cornbread Chemist
Super Slime
Send private message
 
 PostWed Jan 20, 2010 6:09 pm
Send private message Reply with quote
Are you intentionally loading a new sprite each time?
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Liquid Metal Slime
Send private message
 
 PostWed Jan 20, 2010 6:19 pm
Send private message Reply with quote
I think so, because each time it is a different sprite.
Cornbread Chemist
Liquid Metal Slime
Send private message
 
 PostWed Jan 20, 2010 6:43 pm
Send private message Reply with quote
I'd recommend loading the sprite once and then using the if/thens to simply change the image through 'replace medium enemy sprite (handle, num, palette)'

So that you have something like:
Code:

livesbar:= load medium enemy sprite (0)
#Can be anything. Preferably something invisible or the default full bar.
place sprite (livebar, 9, 9)

if(Lives == 1) then(
Replace medium enemy sprite (livesbar, 3)
)

if(Lives == 2) then(
Replace medium enemy sprite (livesbar, 2)
)

if(Lives == 3) then(
Replace medium enemy sprite (livesbar, 1)
)
Liquid Metal Slime
Send private message
 
 PostWed Jan 20, 2010 6:53 pm
Send private message Reply with quote
Done. Thanks for the tip. Is this way less stressful on the game itself?

I'm still having the problem with the sprite staying in the same place though. It seems to hang out right under the portrait sprite. Would that have anything to do with it?

EDIT: Now it is moving properly. Don't know what the problem was, considering I haven't changed the script at all.
Cornbread Chemist
Display posts from previous: