How to place a sprite at coordinates ?

Post Reply
smabasgil
Posts: 46
Joined: Sat Dec 26, 2015 1:06 pm
My devices: Ipad 2
Flag: Bahamas

How to place a sprite at coordinates ?

Post 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 ?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: How to place a sprite at coordinates ?

Post 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.

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How to place a sprite at coordinates ?

Post 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.
The only thing that gets me down is gravity...

smabasgil
Posts: 46
Joined: Sat Dec 26, 2015 1:06 pm
My devices: Ipad 2
Flag: Bahamas

Re: How to place a sprite at coordinates ?

Post 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.

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How to place a sprite at coordinates ?

Post 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. :)
The only thing that gets me down is gravity...

smabasgil
Posts: 46
Joined: Sat Dec 26, 2015 1:06 pm
My devices: Ipad 2
Flag: Bahamas

Re: How to place a sprite at coordinates ?

Post 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 !

Post Reply