LB Booster
Programming >> Liberty BASIC language >> Help moving a sprite
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1434521718

Help moving a sprite
Post by roytt on Jun 17th, 2015, 06:15am

I'm trying to use spritetravelxy to move a sprite from it's current position to the position where the mouse is clicked. All that happens is that the sprite moves to the top left of the window. Any idea what's causing this? Thanks.

Here is the program exe(4.52 mb) with embedded bmp's
https://drive.google.com/file/d/0BxI_7p6wetgmb2M5cmhUWWM2elk/view?usp=sharing

Here is the source
https://drive.google.com/file/d/0BxI_7p6wetgmdG9LYm5lMEdiNEU/view?usp=sharing
Re: Help moving a sprite
Post by tsh73 on Jun 17th, 2015, 06:48am

You are inserting variables into graphical command wrong way.
See this:
Code:
    x = 150 'MouseX
    y = 200 'MouseY
'your line - is wrong
    'print #game, "SPRITETRAVELXY ogre x y 30"
'see why
    print "Wrong:"
    print "SPRITETRAVELXY ogre x y 30"
    print "Right:"
    print "SPRITETRAVELXY ogre ";x;" ";y;" 30"
 


Output: Code:
Wrong:
SPRITETRAVELXY ogre x y 30
Right:
SPRITETRAVELXY ogre 150 200 30
 

Re: Help moving a sprite
Post by roytt on Jun 17th, 2015, 2:13pm

thanks, that did the trick.