Sprite newber question

Post Reply
elbeardo
Posts: 16
Joined: Sat Feb 13, 2016 8:02 am
My devices: iPhone 6s
Flag: Sweden

Sprite newber question

Post by elbeardo »

I'm new to sprites and trying to make a simple camera... I feel stupid asking it but what is wrong with it?

Code: Select all

SET ORIENTATION PORTRAIT

GRAPHICS

OPTION SPRITE POS NORMAL

CAMERA 1 AT BACK VIDEO

SPRITE 2 BEGIN 100,100
GRAPHICS MODE NORMAL
CAMERA 1 SNAPSHOT test
SPRITE 1 LOAD test
SPRITE 2 END
SPRITE 2 SHOW 





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: Sprite newber question

Post by Mr. Kibernetik »

If you want to get a frame from camera footage and display it on the screen then your program can be:

Code: Select all

CAMERA 1 AT BACK VIDEO MEDIUM
PAUSE 0.1
CAMERA 1 SNAPSHOT "test.jpg"
SPRITE 1 LOAD "test.jpg"
SPRITE 1 SHOW
Here I used short pause because camera needs adjustment to light, and if you make a shot immediately after camera creation then it can have wrong brightness.

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: Sprite newber question

Post by Mr. Kibernetik »

If you want to display camera footage on your screen then your program can be:

Code: Select all

CAMERA "cam" AT BACK VIDEO MEDIUM
SPRITE "view" BEGIN 300,300
SPRITE "view" END
SPRITE "view" SHOW
CAMERA "cam" VIEW "view"
1 GOTO 1

elbeardo
Posts: 16
Joined: Sat Feb 13, 2016 8:02 am
My devices: iPhone 6s
Flag: Sweden

Re: Sprite newber question

Post by elbeardo »

Thank you!

But I thought you had to use BEGIN/END for all sprites?

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: Sprite newber question

Post by Mr. Kibernetik »

In first example sprite is created automatically, because its size and contents is defined by loaded image.
In second example you create sprite 300x300 and use it as realtime camera display.

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: Sprite newber question

Post by Mr. Kibernetik »

elbeardo wrote:Thank you!

But I thought you had to use BEGIN/END for all sprites?
You use begin/end if you want to create new sprite manually or if you need to draw in existing sprite.

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: Sprite newber question

Post by Mr. Kibernetik »

Here you create new sprite "0" from image:
sprite 0 load "image.png"

Here you create new sprite "0" with size 100x100 and draw in it:
sprite 0 begin 100,100
' drawing in your sprite here
sprite end

Here you draw in existing sprite "0":
sprite 0 begin
' drawing in your sprite here
sprite end

elbeardo
Posts: 16
Joined: Sat Feb 13, 2016 8:02 am
My devices: iPhone 6s
Flag: Sweden

Re: Sprite newber question

Post by elbeardo »

Thanks, I like small examples.

Post Reply