Create a page

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Create a page

Post by Henko »

Ken wrote:
Mon Feb 18, 2019 3:04 am
Ok I have pasted the code in and checked it out. It works well and is nice and brief. I will try and fit it in with what I want.

However:
It looks like I may have been wasting my time( and yours) since I can't use a created page as a container for graphic objects such as recrtangles and lines.
It seems they can only be drawn on the original page/background.
Is this true?
Yes, that is true. Only objects like switches, buttons, fields, etc. Can be the "childs" of a page.
However, i use to to add "rectangles" and lines to pages using the button object.
Horizontal and vertical lines may be mimiced by boxes with either a very small height or a very small width.

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: Create a page

Post by rbytes »

Sprites can also be children of a page, and can contain anything you want to put into them: lines, text, boxes, circles, even images.
The only thing that gets me down is gravity...

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Create a page

Post by Dutchman »

On viewtopic.php?f=20&t=811 there is a demo-program for pages.
One of these pages shows graphics.
Place a sprite on the page that you fill with graphics, as rbytes said.
Last edited by Dutchman on Thu Jan 19, 2023 3:50 pm, edited 1 time in total.

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Create a page

Post by Henko »

rbytes wrote:
Mon Feb 18, 2019 7:35 am
Sprites can also be children of a page, and can contain anything you want to put into them: lines, text, boxes, circles, even images.
Thanks! I didn't know that :o

matt7
Posts: 115
Joined: Sun Jul 12, 2015 5:00 pm
My devices: iPhone
Location: USA

Re: Create a page

Post by matt7 »

Ken and Henko,

If you are working with sprites across multiple pages you may want to check out my detailed breakdown of how sprite ordering works: Sprite Order Rules
See #11 and #12 in particular if you want to avoid headaches when dealing with sprites not residing on the currently active page.

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: Create a page

Post by rbytes »

I just re-read that post, matt7. I think your sprite ordering information is very valuable, and hope Dutchman will add it to the Smart Basic PDF Manual.
The only thing that gets me down is gravity...

Ken
Posts: 29
Joined: Tue Jan 29, 2019 1:49 am
My devices: Ipad
Location: NSW, Australia

Back to the drawing board

Post by Ken »

Whoops, I didn't read the sprite section at all. It sounds like what I need. I will start nvestigsting it.

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: Create a page

Post by rbytes »

You can do a lot with sprites. Meanwhile, here is a crawling bit of text that shows how you can show credits, etc.

Some things to note:
The moving center page is defined first, then the top and bottom pages.
So they cover the moving page, but because their alpha is less than 1, it shows through a little.
The text is in a field set to a very large font.
Because the text field was created after the center page was active, the field is a child of (attached to) that page.
The field edges don't show, becuase I set the field's BACK ALPHA to zero.
The center page is 3 times as wide as the screen. Therefore you never see the graphics background.
A simple loop keeps the center page scrolling to the left, carrying the field and text with it.
Once the text disappears at the left, the center page jumps back to screen right so fast you don't see it.
Then the loop starts again.
A delay controls the speed, so you can change the delay to speed up or slow down the crawl.

Code: Select all

'Three-page example

Get screen size sw,sh
Graphics
Graphics clear 1,1,1

l$ = "above page"
m$ = "below page"
n$ = "title area"
o$ = "page above"

page n$ set
page n$ show
PAGE n$ color 1,0,0,1
Page n$ Frame 0,sh/4,sw*3,sh/2
FIELD N$ TEXT "Welcome to Hard Times" AT sw+100,150 SIZE 900,80 RO
FIELD N$ FONT SIZE 80
FIELD N$ FONT COLOR 1,1,1
FIELD N$ BACK ALPHA 0

' page at top of screen
PAGE l$ set
PAGE l$ show
PAGE l$ color 0,0,1,1
PAGE l$ Frame 0,0,sw,sh/3
page l$ alpha .6

' page at bottom of screen
PAGE m$ set
PAGE m$ show
PAGE m$ color 1,0,1,1
PAGE m$ Frame 0,2*sh/3,sw,sh/3
page m$ alpha .6


do 
  for t=0 to -sw*2 step -1
    page n$ at t,sh/4
    pause .003
  next t
  get touch 1 as dx,dy
until dx>-1

end
Attachments
64E710E3-2786-4150-9045-3108F36A1FD0.png
64E710E3-2786-4150-9045-3108F36A1FD0.png (82.02 KiB) Viewed 3513 times
The only thing that gets me down is gravity...

Ken
Posts: 29
Joined: Tue Jan 29, 2019 1:49 am
My devices: Ipad
Location: NSW, Australia

Touch scrolling

Post by Ken »

I tried the code supplies by rbytes to scroll a page on the screen under another.
This is the code supplied.

do
get touch 0 as tx,ty
get touch 1 as dx,dy
if tx>-1 then page n$ at tx-sw/2,sh/4
until dx>-1

Very impressive and thanks.
It works nearly the way I wanted and certainly got me started. However I found on the first touch and other touches there was a jump across the screen, before the scrolling started.

I wanted to touch the stylus or my finger on the screen and have the moving page scroll vertically up and down, more or less keeping up with the stylus/finger, with no jumps.

This code below quite well.

graphics
graphics clear 1,1,1

n$= "page1"

page n$ set
page n$ show
page n$ color 1,0,0,1
page N$ frame 300,500,200,200

n2$= "page2"

page n2$ set
page n2$ show
page n2$ color 1,0,1,0.7
page n2$ frame 50,200,800,150

y= 500


loop:

a = touch_y(0)
if a = -1 then goto loop

b = touch_y(0)
if b=-1 then goto loop
if b=a then goto loop

y1=y + (b-a)*2

page n$ at 300,y1

y= y1
goto loop

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: Create a page

Post by rbytes »

This is a good solution. Here is a variation that tightens the loop code (two if statements combined, eliminate gotos (not needed)

I also made a variable spd that determines the distance of page movement relative to finger movement.

Code: Select all

graphics
graphics clear 1,1,1
spd=2   ' scroll speed. try 1, 3, 4

n$= "page1"

page n$ set
page n$ show
page n$ color 1,0,0,1
page N$ frame 300,500,200,200

n2$= "page2"

page n2$ set
page n2$ show
page n2$ color 1,0,1,0.7
page n2$ frame 50,200,800,150

y= 500

loop:

a = touch_y(0)
if a = -1 then loop

b = touch_y(0)
if b=-1 or b=a then loop

y1=y + (b-a)*spd

page n$ at 300,y1

y= y1
goto loop
The only thing that gets me down is gravity...

Post Reply