Pop up window?

Post Reply
Lauderdale
Posts: 13
Joined: Fri Feb 06, 2015 6:49 am
My devices: Iphone 5

Pop up window?

Post by Lauderdale »

Hi :) I'm wondering if it's possible to make a window Pop up from time to time in the middle of the screen with some text and an "ok" button. My white screen is going to be filled with buttons and text so I don't want to write over that. But I guess I could always use input if nothing else.

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: Pop up window?

Post by Mr. Kibernetik »

Please check out PAGE functionality in interface objects.

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

Re: Pop up window?

Post by Henko »


User avatar
Dav
Posts: 279
Joined: Tue Dec 30, 2014 5:12 pm
My devices: iPad Mini, iPod Touch.
Location: North Carolina, USA
Contact:

Re: Pop up window?

Post by Dav »

Pages are great for pop up boxes. You can add buttons and size it and move it to taste.

Here's a popup box using sprites I was working on. It just explodes a pop up box in the center of the screen and shrinks it away. Uses some sound effects. I could'nt use BUTTONS for a real button because BUTTONS don't seem to be scanned by the ' sprite scan '

- Dav

Code: Select all

'
'popup message box by Dav

graphics

shadow on

refresh off

'draw box & border
_line (0,0,300,300,1,1,1,1)
_line (5,5,295,295,1,0,0,1)
_line (0,0,300,300,0,0,0,0)

'draw title & message
_text ("NOTICE",80,20,"",36,1,1,1)
_text ("This is a message",40,80,"",22,0,1,1)
_text ("that can explode",40,110,"",22,0,1,1)
_text ("in and out.",40,140,"",22,0,1,1)

'draw button
_line (100,225,200,275,1,1,1,1)
_line (100,225,200,275,0,0,0,0)
_text ("Close",115,240,"",22,0,0,0)

'Now scan whole box as a sprite
sprite "test" scan 0,0,302,302
sprite "test" show 'turn it on
'move it out of the way
sprite "test" at -2000,-2000

graphics clear 0,0,0

refresh on

'draw something pretty.
for y=0 to screen_height() step 4
   draw color rnd(255)/255,rnd(255)/255,rnd(255)/255
   draw line 0,y to screen_width(),y
next y

pause .5

'find center of screen
'the -150 is half size of our box
x = screen_width()/2-150
y = screen_height()/2-150

'play a sfx for box exploding in...
notes set "9:tc6d6e6f6g6a6b6c7"
notes play

'scale in the message box sprite
for t = 1 to 100 step 2
  sprite "test" at x,y scale t/100
  pause .005
next t

'wait for user to click close

do 
  tx = touch_x(0) ! ty = touch_y(0)
  if tx>x+100 and tx<x+200 then
     if ty>y+225 and ty<y+275 then
        'play a click sfx
        notes set "108:c7" ! notes play
        pause .2 ! break
     end if
  end if
until 0

'play sfx for box going away
notes set "9:tc7b6a6g6f6e6d6c6"
notes play

'dissapear box,scale it out...
for t = 100 to 0 step -2
  sprite "test" at x,y scale t/100
  pause .005
next t

pause .5 

text

end



def _line (x1,y1,x2,y2,fill,r,g,b)
'Combined draw rect,draw line, fill rect
'to this one function, like Qbasic does it.
'Draws a line or box, hollow or filled.
if fill=1 then
  fill color r,g,b
  fill rect x1,y1 to x2,y2
else
  draw color r,g,b
  draw rect x1,y1 to x2,y2
end if
end def

def _text (text$,x,y,font$,size, r,g,b)
'just a one-line way to draw text
if font$<>"" then draw font name font$
if size>0 then draw font size size
draw color r,g,b
draw text text$ at x,y
end def


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: Pop up window?

Post by Mr. Kibernetik »

Dav, very pretty! :lol:

Lauderdale
Posts: 13
Joined: Fri Feb 06, 2015 6:49 am
My devices: Iphone 5

Re: Pop up window?

Post by Lauderdale »

Thanks I appreciates it

Post Reply