#1
|
|||
|
|||
Making buttons appear in scenes
Hey all, I was wondering someone could help me? I'm trying to make a scene-based menu and I can't seem to get buttons and sliders (basically anything that isn't text) to appear in the different scenes. Also, I can't get an image to show up in them either. What am I doing wrong?
Thanks in advance for any help provided. Code:
import viz viz.go() viz.clearcolor(0,0,1) song = viz.add('War Room.mp3') song.play() song.volume(1.0) ########################Title Page############################## #Add New Game transition button to scene 1 (Main Menu). New_Game=viz.addButton() New_Game.translate(0.321,0.572) vizact.onbuttondown( New_Game, viz.scene, 2 ) #Add Tutorial transition button to scene 1 (Main Menu). Tutorial=viz.addButton() Tutorial.translate(0.321,0.419) vizact.onbuttondown( Tutorial, viz.scene, 3 ) #Add Options transition button to scene 1 (Main Menu). Options=viz.addButton() Options.translate(0.321,0.503) vizact.onbuttondown( Options, viz.scene, 4 ) #Add Exit button to scene 1 (Main Menu). Exit=viz.addButton() Exit.translate(0.321,0.316) vizact.onbuttondown( Exit, viz.quit ) #vizact.onkeydown( '1', viz.scene, 1 ) #vizact.onkeydown( '2', viz.scene, 2 ) #vizact.onkeydown( '3', viz.scene, 3 ) #vizact.onkeydown( '4', viz.scene, 4 ) ########################Tutorial################################ vizact.onkeydown(' ', viz.window.hideHTML ) s1 = viz.addButton(viz.WORLD, 3) s1.translate(.045,.082) s1.visible(viz.OFF) s2 = viz.addButton() s2.translate(.380,.082) s2.visible(viz.OFF) s3 = viz.addButton() s3.translate(.670,.082) s3.visible(viz.OFF) def Help(obj,state): if obj == Tutorial: if state == viz.pick: viz.window.displayHTML( '1.htm' ) s1.visible(viz.ON) s2.visible(viz.ON) s3.visible(viz.ON) viz.callback(viz.BUTTON_EVENT,Help) Title = viz.addText('TUTORIAL', viz.SCREEN, 3) Title.translate(.319, 0.898) Title.color(0,0,0) Basic = viz.addText('BASIC MOVES', viz.SCREEN, 3) Basic.translate(.066, 0.066) Basic.color(0,0,0) Basic.fontSize(45) Main = viz.addText('MAIN MENU', viz.SCREEN, 3) Main.translate(.401, 0.066) Main.color(0,0,0) Main.fontSize(45) Special = viz.addText('SPECIAL MOVES', viz.SCREEN, 3) Special.translate(.690, 0.066) Special.color(0,0,0) Special.fontSize(45) def onButton(obj,state): if obj == s1: if state == viz.DOWN: viz.window.displayHTML( '1.htm' ) elif obj == s3: if state == viz.DOWN: viz.window.displayHTML( '2.htm' ) elif obj == s2: if state == viz.DOWN: viz.window.hideHTML() s3.remove() viz.callback(viz.BUTTON_EVENT,onButton) ########################Options################################# def music(obj, pos): song.volume(1.0*pos) viz.callback(viz.SLIDER_EVENT,music) #Title: Options _Options = viz.addText( 'Options', viz.SCREEN, 4 ) _Options.setScale(1.0, 1.0 ) #Position _Options.translate( .093, .856) #text_2D.color _Options.color( 0.753, 0.753, 0.753 ) #Title: Graphics _Graphics = viz.addText( 'Graphics', viz.SCREEN, 4 ) _Graphics.setScale(0.700, 0.700 ) #Position _Graphics.setPosition( .150, .688) #text_2D.color _Graphics.color( 0.753, 0.753, 0.753 ) #Title: Effects Effects = viz.addText( 'Effects', viz.SCREEN, 4 ) Effects.setScale(0.700, 0.700 ) #Position Effects.setPosition( .150, .618) #text_2D.color Effects.color( 0.753, 0.753, 0.753 ) #Title: Music Volume mv = viz.addText( 'music volume', viz.SCREEN, 4 ) mv.setScale(0.700, 0.700 ) #Position mv.setPosition( .150, .469) #text_2D.color mv.color( 0.753, 0.753, 0.753 ) ##slider,pos,orientation music = viz.addSlider(viz.WORLD, 4) #Add a slider. music.set(1.0) music.setPosition(.669,.488) #Set its position. music.setScale(1,1) music.ticksize(1,1) #Increase the size. #Title: Main Menu _Exit = viz.addText( 'Main Menu', viz.SCREEN, 4 ) _Exit.setScale(0.900, 0.900 ) #Position _Exit.setPosition( 0.239, 0.182 ) #text_2D.color _Exit.color( 0.753, 0.753, 0.753 ) #exitBtn Mainmenu = viz.addButton(viz.SCREEN, 4) Mainmenu.translate(.146,.206) Mainmenu.setScale(4.521, 1.398 ) #Title: Size1 #640 X 380 _Size1 = viz.addText( '640 X 380', viz.SCREEN, 4 ) _Size1.setPosition( .589, .726) _Size1.setScale(0.600, 0.600 ) #color _Size1.color( 0.753, 0.753, 0.753 ) #s1 s1 = viz.addButton(viz.SCREEN, 4) s1.translate(.569,.745) s1.setScale(1, 1 ) #Title: Size2 #1024 X 768 _Size2 = viz.addText( '800 X 600', viz.SCREEN, 4 ) _Size2.setPosition( .452, .634) _Size2.setScale(0.600, 0.600 ) #color _Size2.color( 0.753, 0.753, 0.753 ) #s2 btn s2 = viz.addButton(viz.SCREEN, 4) s2.translate(.429,.651) s2.setScale(1, 1 ) #Title: Size3 #640 X 480 _Size3 = viz.addText( '1024 X 768', viz.SCREEN, 4 ) _Size3.setPosition( .742, .634) _Size3.setScale(0.600, 0.600 ) #color _Size3.color( 0.753, 0.753, 0.753 ) #s3 btn s3 = viz.addButton(viz.SCREEN, 4) s3.translate(.720,.653) s3.setScale(1, 1 ) #Resolution function def Res(obj,state): if obj == s1: if state == viz.DOWN: viz.window.setSize(640, 380) #Sets to this 640x380 elif obj == s2: if state == viz.DOWN: viz.window.setSize(800, 600) #Sets to this 800x600 elif obj == s3: if state == viz.DOWN: viz.window.setSize(1024,736) #Sets to this 1024x736 viz.callback(viz.BUTTON_EVENT,Res) ########################Exit################################ #Insert Exit Page here later |
#2
|
|||
|
|||
Nevermind! Figured it out.
Code:
s1 = viz.addButton(viz.Scene3) Code:
s1 = viz.addButton(viz.SCREEN, 3) |
#3
|
|||
|
|||
Alright, new question. Why does the screen sometimes crash when trying to implement a slider? I still can't get it to appear without messing up the 'run' window.
|
#4
|
|||
|
|||
My guess is it has something do with your function that is called when a slider event occurs. Could you narrow down this code to show a slider that replicates the problem. What kind of error are you getting?
|
#5
|
|||
|
|||
Code:
##slider,pos,orientation music = viz.addSlider(viz.scene4) #Add a slider. music.set(1.0) music.setPosition(.669,.488) #Set its position. music.setScale(1,1) music.ticksize(1,1) #Increase the size. I just tried to implement a slider on another computer and it works fine, and the slider is the only problem on this one. I wonder what the problem is exactly? |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help With Creating Menus and Buttons for a Chess Game | RodRSpv | Vizard | 1 | 02-27-2009 02:12 PM |
Arranging Scenes in Correct Order | utepbereed | Vizard | 1 | 11-21-2008 09:19 AM |
What are the options for making a movie of a Vizard world? | Karla | Vizard | 1 | 05-13-2008 10:56 AM |
Buttons Not rendering to both Eyes in 3d | shivanangel | Vizard | 2 | 05-24-2007 06:58 AM |
environment maps, scenes, and you! | vadrian | Vizard | 1 | 01-12-2005 04:04 PM |