Make your own apps, the easy way

Discussion in 'iPod touch Hacks' started by pimmysays, Dec 30, 2007.

  1. pimmysays macrumors member

    Joined:
    Oct 1, 2007
    #1
    I don't know if you guys noticed but you can now make your own iphone/ipod touch apps real easily with an app called Jiggy which is based on javascript. I don't even know javascript (I know java and C) and i'm able to make simple but fun programs. Check it out on installer or go to their website http://jiggyapp.com/ .
     
  2. jacktiernan macrumors regular

    Joined:
    Sep 3, 2007
    Location:
    Vic, Australia
    #2
    Nice. Thanks for posting.
     
  3. pimmysays thread starter macrumors member

    Joined:
    Oct 1, 2007
    #3
    I've been messing around for a few hours and here's my first attempt at a javascript program, its a number guessing game. Its very basic so hopefully it will help some of you out who have never worked with javascript before (like me!), good luck! If any one else makes a program with jiggy be sure to post it!

    //pim's iphone app
    //************************MAIN************************
    Plugins.load( "UIKit" );

    var window = new
    UIWindow( UIHardware.fullScreenApplicationContentRect );
    window.setHidden( false );
    window.orderFront();
    window.makeKey();
    //red, green, blue, fill
    window.backgroundColor = [ 1, 1, 1, 1 ];

    var mainView = new UIScroller();
    //background
    mainView.backgroundColor = [1, 1, 1, 1];
    window.setContentView( mainView );
    //************************KEYBOARD************************
    var keyboard= new UIKeyboard();
    mainView.addSubview( keyboard );
    keyboard.activate();

    //************************RANGEL************************
    //leftright,updown,width, height
    var rangel= new UITextLabel( [ 0, 0, 320, 25] );
    rangel.text = "Range of numbers";
    rangel.centersHorizontally = true;
    rangel.setFont( new Font( "Trebuchet MS" , 2 , 18) );
    rangel.backgroundColor = [ 1, 1, 1, 1 ];
    //************************LOWRANGEL************************
    var lowrangel= new UITextLabel( [57, 25, 100, 25] );
    lowrangel.setFont( new Font( "Trebuchet MS" , 2 , 18) );
    lowrangel.text = "From:";
    rangel.centersHorizontally = true;
    //************************LOWRANGE************************
    var lowrange = new UITextField( [ 30, 50, 100, 35] );
    lowrange.backgroundColor = [ 1, 1, 1, 1 ];
    lowrange.setBorderStyle(1);
    //************************HIGHRANGEL************************
    var highrangel= new UITextLabel( [ 227, 25, 100, 25] );
    highrangel.setFont( new Font( "Trebuchet MS" , 2 , 18) );
    highrangel.text = "To:";
    //************************HIGHRANGE************************
    var highrange = new UITextField( [ 190, 50, 100, 35] );
    highrange.backgroundColor = [ 1, 1, 1, 1 ];
    highrange.setBorderStyle(1);
    var tmp2= 0;
    var count = 0;
    //************************GUESSL************************
    var guessl= new UITextLabel( [ 0, 85, 320, 25] );
    guessl.setFont( new Font( "Trebuchet MS" , 2 , 18) );
    guessl.text = "Guess";
    guessl.centersHorizontally = true;
    guessl.backgroundColor = [ 1, 1, 1, 1 ];
    //************************GUESS************************
    var guess = new UITextField( [ 110, 110, 100, 35] );
    guess.backgroundColor = [ 1, 1, 1, 1 ];
    guess.setBorderStyle(1);
    //************************ANS************************
    var ans= new UITextField( [ 0, 150, 320, 25] );
    ans.setFont( new Font( "Trebuchet MS" , 2 , 18) );
    ans.centersHorizontally = true;
    ans.text="";
    ans.backgroundColor = [ 1, 1, 1, 1 ];
    //************************WIN************************
    var win= new UITextField( [ 0, 175, 320, 25] );
    win.setFont( new Font( "Trebuchet MS" , 2 , 18) );
    win.centersHorizontally = true;
    win.text="";
    win.backgroundColor = [ 1, 1, 1, 1 ];
    //************************RAN************************
    var ran= new UITextField( [500, 300,0, 0] );
    ran.text="";
    //************************BUTTON************************
    var btn = new UINavigationBar( [0, 200, 320, 45] );
    btn.showButtonsWithLeftTitle(null,"Enter",0);
    btn.centersHorizontally = true;
    btn.backgroundColor = [ 1, 1, 1, 1 ];
    btn.onMouseDown = function(event) {
    calc();
    }
    btn.onMouseUp = function( event) {
    calc();
    }
    function calc()
    {
    while(tmp2==0)
    {
    var from = parseInt(lowrange.text);
    var to = parseInt(highrange.text);
    var ranNum = Math.floor((from)+Math.random()*(to-from+1));
    //random num equals
    ran.text = ranNum;
    tmp2=1;
    };
    count++;
    var tmp = parseInt(ran.text);
    var num = parseInt(guess.text);
    if(num<=tmp)
    ans.text = "My number is greater than "+guess.text;
    if(num>=tmp)
    ans.text = "My number is less than "+guess.text;
    if(num==tmp)
    {
    ans.text = "You got it! My number was " +guess.text;
    win.text = "It took you "+count+" tries"
    lowrange.text = "";
    highrange.text = "";
    tmp2=0;
    count=0;
    }
    guess.text = null;


    }
    //************************DISPLAY************************
    mainView.addSubview( rangel);
    mainView.addSubview( lowrange);
    mainView.addSubview( highrange);
    mainView.addSubview( lowrangel);
    mainView.addSubview( highrangel);
    mainView.addSubview( ans);
    mainView.addSubview( win);
    mainView.addSubview( ran);
    mainView.addSubview( guessl);
    mainView.addSubview( guess);
    mainView.addSubview( btn );
     

Share This Page