Showing posts with label cancel. Show all posts
Showing posts with label cancel. Show all posts

Wednesday, 7 August 2013

How to create a native alert view using corona SDK



The below function defines the two alert button ('Learn More' & 'OK') actions:

local function onClick(e) 
    if e.action == "clicked" then 
        if e.index == 1 then 
            -- Do something
        elseif e.index == 2 then 
            system.openURL( "http://devblogdk.blogspot.in/" ) 
        end 
    end 
end 

The below code generates the native alertview with title, subject and two buttons:

local alert = native.showAlert("Welcome", "Development Tutorials on DevBlogDK", {"OK", "Learn More"}, onClick)

Friday, 31 May 2013

How to call a function directly/with scheduler and cancel scheduler: cocos2d

In cocos2d, the function call can be either direct call without any delay, or scheduled call with a delay.

In direct call, the syntax is as follows:

      [self functionName];                                    // to call a function without delay


In scheduled function call, the syntax is:

    [self schedule:@selector(functionName) interval:10];    // to call a function with delay = 10min.s.

Note:   If the function is called with a selector with specified time interval(say 10min, as above), then it will get called in every repeated,specified time intervals(in the above case, it will trigger in every 10 min.s). So, if you need to stop the function getting called repeatedly, you can simply use the following line inside the called function at it's beginning.



       [self unschedule:_cmd];           

       example:                  
              function (normal):

                  -(void)myFunction{
                          .............................
                          .............................
                          .............................
                    }









              scheduled call:

                  [self schedule:@selector(myFunction) interval:2];

              to stop the function from getting called per each 2 mins, 
              rewrite the function as follows:

                     -(void)myFunction{
                          [self unschedule:_cmd];           // this will unschedule the scheduler
                          .............................
                          .............................
                          .............................

                    }