Removing Subviews

Discussion in 'Jiggy Runtime Development' started by SixSixSix, Feb 25, 2009.

  1. SixSixSix

    SixSixSix New Member

    Joined:
    Oct 4, 2008
    Messages:
    10
    Likes Received:
    0
    Hey! I'm making an app with Jiggy (yes, it still exists, I know I'm the only person in the world that still plays with that, but please could you kindly SHUT UP AND STOP SAYING I'M A F***ING RETARDED!!!) Where was I... Oh yeah, I'm making this app called iGuess but I'm having problems with (drum roll, please) removing a subview. Example, I'm trying every code I know or I think they work but I kinda have some problems. Here's what I try:
    Code:
          gameView.[U]deleteSubview[/U]( rightCloseLose );
          gameView.[U]deleteSubview[/U]( leftOpenWin );
          gameView.[U]deleteSubview[/U]( leftCloseLose );
          gameView.[U]deleteSubview[/U]( rightOpenWin );
    Or even:
    Code:
          gameView.[U]removeSubview[/U]( rightCloseLose );
          gameView.[U]removeSubview[/U]( leftOpenWin );
          gameView.[U]removeSubview[/U]( leftCloseLose );
          gameView.[U]removeSubview[/U]( rightOpenWin );
    But none of them work. Can some please help me? (Helping is different from saying I'm a f***ing retarded, ok guys?)

    By the way, I don't care if anyone copies this speech and puts it at his/hers signature.
  2. SixSixSix

    SixSixSix New Member

    Joined:
    Oct 4, 2008
    Messages:
    10
    Likes Received:
    0
    I've fixed some things in the code and here it is:

    Code:
    //Load plugins
    Plugins.load( "UIKit" );
    
    //Creates the application window
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    window.backgroundColor = [ 0 , 0 , 0 , 1 ];
    
    //Creates the Main View and sets it as default
    var mainView = new UIView();
    window.setContentView( mainView ); 
    
    //Creates the game 6 possible Views
    var LCW = new UIView();
    var RCW = new UIView();
    var LOW = new UIView();
    var ROW = new UIView();
    var LOL = new UIView();
    var ROL = new UIView();
    
    //Adds all the images to the game (it'll be easier to use
    //them later if they are like this)
    var backgroundPNG = Images.imageWithContentsOfFile(Bundle.bundlePath+"/bg.png", false);
    var normalPNG = Images.imageWithContentsOfFile(Bundle.bundlePath+"/normal.png", false);
    var winPNG = Images.imageWithContentsOfFile(Bundle.bundlePath+"/win.png", false);
    var losePNG = Images.imageWithContentsOfFile(Bundle.bundlePath+"/lose.png", false);
    
    //Creates the Background and adds it to the screen
    var bgView = new UIImageView(backgroundPNG);
    bgView.onTap =function (tapCount){
    if (tapCount==1) openURL( "http://nowayyoucangethere.wordpress.com/2008/09/12/iguess/" , true);
    }
    mainView.addSubview( bgView );
    
    //Creates the Navigation Bar, Buttons, Title etc. 
    var navBar = new UINavigationBar( [ 0 , 0 , 320 , 44 ] );
    navBar.showButtonsWithLeftTitle( "Donate" , "Play" , false );
    var navTitle = new UINavigationItem( "iGuess" );
    navBar.pushNavigationItem( navTitle );
    navBar.onButtonClicked = function(navBar,buttNo){ 
    if (buttNo == 1) 
          openURL( "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ericpires@uol.com.br&item_name=iGuess%20Donation&no_shipping=1&return=http://nowayyoucangethere.wordpress.com/2008/09/12/iguess/&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8" , true);
    else 
      play();
    } 
    
    //Adds the Nav Bar to the screen
    mainView.addSubview( navBar );
    
    //****IMPORTANT****
    //
    //Now it starts the code for the gameView (in-game UIView), so
    //please pay a lot of attention now, since the main idea of
    //the scripting changes.
    //----------------------------------------------------------*/
    
    //****SHEETS LIST****
    //To make everything easier, I've listed together all the sheet
    //alerts that I use in the game. So here they are:
    
    //The victory sheet
    var winSheet = new UIAlertSheet("***YOU WON***", [ "Play Again", "Quit" ], 2);
    winSheet.setBodyText("Wow! You've found the ball!")
    winSheet.onButtonClicked = function(buttonClicked){
        if (buttonClicked==2){
          winSheet.dismiss( true );  
          terminate();
        }
        else {
          winSheet.dismiss(true);
          play();
    }}
    
    //The loose sheet
    var loseSheet = new UIAlertSheet("***YOU LOST***", [ "Play Again", "Quit" ], 2);
    loseSheet.setBodyText("Sorry. Better luck next time!")
    loseSheet.onButtonClicked = function(buttonClicked){
          if (buttonClicked==2){
          winSheet.dismiss( true );  
          terminate();
        }
        else {
          loseSheet.dismiss(true);
          play();
    }}
    
    //Now I create one image for each element that can appear on
    //the game, that means, the bowls possibilities plus the
    //possible results (8 in total)
    
    //The closed bowls...
    var leftCloseWin = new UIImageView(normalPNG);
    leftCloseWin.position=[96,96];
    leftCloseWin.onTap =function (tapCount){
    if (tapCount==1)
      window.setContentView(LOW);
      winSheet.popupAlertAnimated( true ); 
    }
    var leftCloseLose = new UIImageView(normalPNG);
    leftCloseLose.position=[96,96];
    leftCloseLose.onTap =function (tapCount){
    if (tapCount==1)
      window.setContentView(LOL); 
      loseSheet.popupAlertAnimated( true ); 
    }
    var rightCloseWin = new UIImageView(normalPNG);
    rightCloseWin.position=[96,256];
    rightCloseWin.onTap =function (tapCount){
    if (tapCount==1)
      window.setContentView(ROW);
      winSheet.popupAlertAnimated( true );
    }
    var rightCloseLose = new UIImageView(normalPNG);
    rightCloseLose.position=[96,256];
    rightCloseLose.onTap =function (tapCount){
    if (tapCount==1)
      window.setContentView(ROL);
      loseSheet.popupAlertAnimated( true );
    }
    
    //...and the opened ones.
    var leftOpenWin = new UIImageView(winPNG);
    leftOpenWin.position=[96,96];
    var leftOpenLose = new UIImageView(losePNG);
    leftOpenLose.position=[96,96];
    var rightOpenWin = new UIImageView(winPNG);
    rightOpenWin.position=[96,256];
    var rightOpenLose = new UIImageView(losePNG);
    rightOpenLose.position=[96,256];
    
    //This code shows where there'll be each object
    LCW.addSubview(leftCloseWin);
    LCW.addSubview(rightCloseLose);
    
    RCW.addSubview(leftCloseLose);
    RCW.addSubview(rightCloseWin);
    
    LOW.addSubview(leftOpenWin);
    LOW.addSubview(rightCloseLose);
    
    LOL.addSubview(leftOpenLose);
    LOL.addSubview(rightCloseWin);
    
    ROW.addSubview(rightOpenWin);
    ROW.addSubview(leftCloseLose);
    
    ROL.addSubview(rightOpenLose);
    ROL.addSubview(leftCloseWin);
    
    //This function "restarts" the game.
    function play(){
      this.value = (Math.random( ) );{
        if (this.value > 0.5){
          window.setContentView(LCW);
          }
        else{
          window.setContentView(RCW);
    }}}
    I can't understand why there isn't any bowls???

Share This Page