Page 1 of 1
How to place a sprite at coordinates ?
Posted: Tue Apr 11, 2017 2:42 pm
by smabasgil
Hello, i am new to sprites.
i did not find in the doc within the app how to position a sprite.
The sprites i intend to use are there only to display images files, no other usage.
When i issue the commands:
sprite NS$ load "MyFile.png"
sprite show
The sprite displays at 0,0
This is okay and i understand it, but with what command can you tell SB to display AT x,y ?
Re: How to place a sprite at coordinates ?
Posted: Tue Apr 11, 2017 2:59 pm
by Mr. Kibernetik
Please read documentation about sprites. For example this command does what you want:
SPRITE n$ AT x,y SCALE s ANGLE a FLIP k
There are also many program samples which use sprites.
Re: How to place a sprite at coordinates ?
Posted: Tue Apr 11, 2017 3:07 pm
by rbytes
The commands you need are these, but you only use one of them at a time:
SPRITE N$ AT X,Y SCALE S ANGLE A FLIP K
SPRITE N$ AT X,Y SCALE SX,SY ANGLE A FLIP K
WIth one of the above commands you can position the Sprite At X, Y
By default, X and Y set the top left corner location, the same as if you first use the command OPTION SPRITE POS NORMAL
You can change this using OPTION SPRITE POS CENTRAL so that X and Y position the center of the Sprite.
Notice that the first command always maintains the shape, while the second command lets you squash or stretch the image.
There is more information in the manual.
Re: How to place a sprite at coordinates ?
Posted: Wed Apr 12, 2017 9:34 am
by smabasgil
Thank you.
It was because i once decided not to 'enter' into the sprites usage, since i estimated it was hard to master, and not serving my purpose.
So when i went browsing the manual about sprites, my eye preview the commands and the ones finishing with SCALEs ANGLEs and FLIPs made me run !
It is okay now i only issue the first part of the command, ignoring SCALEs ANGLEs and FLIPs. Perhaps i will use SCALE in a day or two !
I appreciate your help and wish you a pleasant day.
Re: How to place a sprite at coordinates ?
Posted: Wed Apr 12, 2017 2:18 pm
by rbytes
I find SCALE very useful to set the Sprite size for different devices, and in a loop you can smoothly grow or shrink the size. ANGLE allows for nice rotations, but it is advisable to set OPTION ANGLE DEGREES first. If you leave the default (RADIANS), the rotation will be harder to calculate. I have not yet used FLIP.
Re: How to place a sprite at coordinates ?
Posted: Wed Apr 12, 2017 3:15 pm
by smabasgil
"
I find SCALE very useful to set the Sprite size for different devices, and in a loop you can smoothly grow or shrink the size
"
Oh yes !