The Basics: Starting Jiggy Dev: Basic Application #1

Discussion in 'Jiggy Runtime Development' started by gojohnnyboi, Apr 23, 2008.

  1. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Ok, so in this thread i will explain the howto basics of making a basic application.


    Ok, so first you must make a window. This is a MUST. NO QUESTIONS ASKED...

    Code:
    var window = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.orderFront();
    window.makeKey();
    window.setHidden( false );
    window.backgroundColor = [ 1 , 1 , 1 , 1 ];
    
    This makes a window. fullScreenApplicationContentRect = a rectangular window. Simple as that. This will not show up until you make a view, which is our next step, and is also neccessary. You can change the color codes of the window to something else.

    Green = [ 0 , 1 , 0 , 1 ];
    Black = [ 0 , 0 , 0 , 255 ];
    Blue = [ 0 , 0 , 2 , 255 ];

    There are more codes, so just experiment a little.


    Code:
    var mainView = new UIView()
    window.setContentView( mainView );
    
    This creates a user view, and sets the content of the window you made earlier to this view. Later on when you create other objects, you can simply add them to this view and they will show up.


    Now, we can create a Navigation bar, other wise known as the nice little blue bar at the top of the screen of applications.

    Code:
    var bar = new UINavigationBar( [0 , 0 , 320 , 48] );
    bar.setBarStyle(0);
    bar.showButtonsWithLeftTitle(null , "About");
    var title = new UINavigationItem( "Application" );
    bar.pushNavigationItem( title );
    bar.onButtonClicked = function( bar , button )
    {
    if ( button == 0 )
    {
    sheet.popupAlertAnimated( true );
    }
    };
    mainView.addSubview( bar );
    This will make a bar at the top of the screen, default size, with a right button that simply activates one of my alertsheets. If you were to set it to true in the buttons setter, the left button would be the back arrow, which is nice looking. The UINavigationItem is the title for the bar, and is very useful. When working with buttons of the navbar, remember that for some reason the parameters read right to left and the right button starts at 0, not 1. It's weird but theres nothing we can do about it.


    If you want the screen to do something when tapped, simply add a tap function to your UIView, like this:

    Code:
    var mainView = new UIView()
    window.setContentView( mainView );
    mainView.onTap = function()
    {
    // stuff to do here
    }
    
    This makes something happen when the user taps the screen.


    Now, the AlertSheet is a powerful thing. It can be made like this:

    Code:
    var sheet = new UIAlertSheet( "" , [ "Button1" , "Button2" ] , 0 );
    sheet.setAlertSheetStyle(0);
    sheet.setTitle( "AlertSheet Title" );
    sheet.setBodyText( "Text of the body of the alertsheet" );
    sheet.onButtonClicked = function( button )
    {
    if ( button == 1 )
    {
    // command to execute or function
    }
    if ( button == 2 )
    {
    // command or function for button2
    }
    };
    
    
    Now, you can alter this as you wish, and add more buttons, or even have only 1, or even 0 buttons. It's your choice. You'll notice the alertsheet does not open on its own, and is triggered by one of a series of command, which can be called in a function ( {} ):

    Code:
    sheet.popupAlertAnimated( true ); // standard popup, animation, looks good
    sheet.presentSheetFromAboveView( mainView ); // when the view to popup from is set, it comes up from the bottom like installer, and looks sharp
    
    Choose your method, and have fun with it.

    If you wish to have a background image for your application, use an imageview like this:

    Code:
    var background = new UIImageView( new Image( "Background.png" );
    mainView.addSubview( background );
    
    This adds to the screen an image IN THE DIRECTORY OF THE APPLICATION, named background, and of the type .png. You will get an error if the image you state is not in the application directory, so make sure you have it. MAKE IT 320 x 480 or 460, not sure exactly.


    These are some basics, so stay tuned for a more detailed lesson ( #2 ) later this week, with a sample application to go along with it.


    Thanks,
    Gojohnnyboi
  2. The Ax

    The Ax Banned

    Joined:
    Mar 11, 2008
    Messages:
    647
    Likes Received:
    22
    or siimply
    Code:
    [COLOR="Green"]Green [/COLOR]= [ 0 , 1 , 0 , 1 ];
    [COLOR="Black"]Black[/COLOR] = [ 0 , 0 , 0 , 1 ];
    [COLOR="Blue"]Blue[/COLOR] = [ 0 , 0 , 1 , 1 ];
    [COLOR="Red"]Red [/COLOR]=[ 1 , 0 , 0 , 1]
  3. immortal7792

    immortal7792 New Member

    Joined:
    Mar 13, 2008
    Messages:
    164
    Likes Received:
    3
    can someone tell me how this kid is like. i started learning jiggy today like 2 days ago. and all of a sudden hes a pro.
  4. hockeypanda32

    hockeypanda32 Well-Known Member

    Joined:
    Dec 18, 2007
    Messages:
    2,183
    Likes Received:
    89
    Device:
    iPhone 4 (Black)
    Well what??? Are you talking about GoJohnnyBoi, he has been a Jiggy Dev for a while now, he is pretty helpful also, if that is what ya mean! A lot of Jiggy devs learn quick, i myself did, it is a pretty easy programming language, javascript.
  5. immortal7792

    immortal7792 New Member

    Joined:
    Mar 13, 2008
    Messages:
    164
    Likes Received:
    3
    where did you learn it. the last post i saw from him was the reboot app. in that he said he started learning jiggy.
  6. micaheljcaboose

    micaheljcaboose Well-Known Member

    Joined:
    Jan 20, 2008
    Messages:
    1,855
    Likes Received:
    82
    I made my first app in 2 days. iPickup Line was made 2 days after I started learning jiggy.
  7. hockeypanda32

    hockeypanda32 Well-Known Member

    Joined:
    Dec 18, 2007
    Messages:
    2,183
    Likes Received:
    89
    Device:
    iPhone 4 (Black)
    Yep, se another example, plus I made my first app in 2 days also!
  8. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    yup, pretty simple. im into obj-c now but i thot ide whip up a quick guide for pplz
  9. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    BUmP bUMp BuMP
  10. Johnny Quest

    Johnny Quest Active Member

    Joined:
    Nov 23, 2007
    Messages:
    1,012
    Likes Received:
    12
    Device:
    iPhone 6
    Dude you're awesome. I'm trying to learn it now. I've had this "Java in 21 days" book for the longest. It was sent to me from AOL about 7 years ago. Is the language still the same. Should I even start reading this book? or should I just buy another one?

Share This Page