Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 12 of 12
  1. #1
    Join Date
    Dec 2005
    Posts
    11

    How can i make 2 Timer in page

    how can i make 2 timar :

    ex: Page.StartTimer(5000); && Page.StartTimer(200);
    in the same page, how??????????

  2. #2
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Hi, simply find the lowest common denominator between the various timings you need, and then treat those as units.

    So for example, let's say I have one event which repeats every second and one which repeats every second and a half. Then I would simply set the timer to increment twice per second and track each event accordingly.

  3. #3
    Join Date
    Dec 2005
    Posts
    11

    sorry

    sorry i can't understand , can u make a sample please

  4. #4
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Here's an example that may help you out.
    http://www.indigorose.com/forums/sho...2&postcount=19

  5. #5
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    Another way to do that, especially if you cannot find a "common denominator" and you want something different happening in your timer action, is to use a bunch of "if", maybe even bundling them all inside a global function.
    You would then set a relevant variable when launching the pagetimer so that when the PageTimer is invoked, it will run the relevant code based on that variable.
    BTW, this is where an ObjectTimer would come handy....

    Yossi

  6. #6
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    FWIW it's fairly easy to create code based object timers with the existing system also.

  7. #7
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020
    Quote Originally Posted by yosik
    Another way to do that, especially if you cannot find a "common denominator" and you want something different happening in your timer action, is to use a bunch of "if", maybe even bundling them all inside a global function.
    You would then set a relevant variable when launching the pagetimer so that when the PageTimer is invoked, it will run the relevant code based on that variable.
    BTW, this is where an ObjectTimer would come handy....

    Yossi
    Object Timer ?? Wow... do we have it?
    Newbie Examples
    ------> AMS 7.5 : amstudio.azman.info
    ----> AMS 6 & 5: www.azman.info/ams/
    ----> FB: facebook.com/GuideToWealth

    ----> Content Development Blog: www.AZMAN.asia

  8. #8
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    No, there's no such thing per se, but it would be easy to write one. It all depends on what you're trying to time.

  9. #9
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020
    Quote Originally Posted by Corey
    No, there's no such thing per se, but it would be easy to write one. It all depends on what you're trying to time.
    Ahhh....ok.

    Sometimes, at specific timings, we need to change object content, Label Text or Image for instance.

    This is suitable for making simple games for children. They type correct spellings into an input box at a given time based on an Image and an Anagram Label before another Image and Anagram appears.

    Like you say, it is easily coded. But if there is an Object Timer, it would be fantastic - like a non-linear tool or storyboard of objects.
    Newbie Examples
    ------> AMS 7.5 : amstudio.azman.info
    ----> AMS 6 & 5: www.azman.info/ams/
    ----> FB: facebook.com/GuideToWealth

    ----> Content Development Blog: www.AZMAN.asia

  10. #10
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Yes a separate "On Timer" event for every object would be handy for some stuff. You should add that to the suggestions forum.

  11. #11
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    sorry i can't understand , can u make a sample please
    I just did this for a pong-like game. I needed one timer to control the refresh rate for moving objects (like the ball and paddles). The other timer controls the delay of the computer controlled paddle (otherwise it is impossible to win).

    To do this I start the timer for the current page and define the delay(s) I intend to use (I do this On Key, but you could do this On Show or anywhere else except On Timer):

    Code:
    Page.StartTimer(10);	
    g_OppDelay = 3;
    Now I set your preferred actions On Timer event for the page like moving the ball:

    Code:
    -- Move the ball
    Image.SetPos("imgBall", t_BallPos.X + g_XBallMotion, t_BallPos.Y + g_YBallMotion);
    For the actions that I want to run less frequently, I setup a counter to that triggers the action and resets when the interval is reached:

    Code:
    -- Setup a counter to control delays on the opponent's paddle
    if g_TimeCount > g_OppDelay then
    	g_TimeCount = 0
    else
    	g_TimeCount = g_TimeCount + 1;
    end
    
    -- Check to see if the delay has expired and if so, allow the opponent to check which direction it should be going
    if g_TimeCount == g_OppDelay then
    	t_OppPos.X = Image.GetPos("imgOpp");
    	if t_OppPos.X <= g_WestWall and g_XBallState < 0 then
    		g_XOppState = 0;
    	elseif (t_OppPos.X + g_PaddleSize) >= g_EastWall and g_XBallState > 0 then
    		g_XOppState = 0;
    	else
    		if (t_OppPos.X + (g_PaddleSize / 2) - t_BallPos.X + (g_BallSize / 2)) > 0 then
    			g_XOppState = -1;
    		elseif (t_OppPos.X + (g_PaddleSize / 2) - t_BallPos.X + (g_BallSize / 2)) < 0 then
    			g_XOppState = 1;
    		else
    			g_XOppState = 0;
    		end
    	end
    end
    I suspect that my example is not exactly (your probably working on something more productive ) to what you are trying to accomplish, but I think the concept would be the same.

  12. #12
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    sorry i can't understand , can u make a sample please
    I just did this for a pong-like game. I needed one timer to control the refresh rate for moving objects (like the ball and paddles). The other timer controls the delay of the computer controlled paddle (otherwise it is impossible to win).

    To do this I start the timer for the current page and define the delay(s) I intend to use (I do this On Key, but you could do this On Show or anywhere else except On Timer):

    Code:
    Page.StartTimer(10);	
    g_OppDelay = 3;
    Now I set your preferred actions On Timer event for the page like moving the ball:

    Code:
    -- Move the ball
    Image.SetPos("imgBall", t_BallPos.X + g_XBallMotion, t_BallPos.Y + g_YBallMotion);
    For the actions that I want to run less frequently, I setup a counter to that triggers the action and resets when the interval is reached:

    Code:
    -- Setup a counter to control delays on the opponent's paddle
    if g_TimeCount > g_OppDelay then
    	g_TimeCount = 0
    else
    	g_TimeCount = g_TimeCount + 1;
    end
    
    -- Check to see if the delay has expired and if so, allow the opponent to check which direction it should be going
    if g_TimeCount == g_OppDelay then
    	t_OppPos.X = Image.GetPos("imgOpp");
    	if t_OppPos.X <= g_WestWall and g_XBallState < 0 then
    		g_XOppState = 0;
    	elseif (t_OppPos.X + g_PaddleSize) >= g_EastWall and g_XBallState > 0 then
    		g_XOppState = 0;
    	else
    		if (t_OppPos.X + (g_PaddleSize / 2) - t_BallPos.X + (g_BallSize / 2)) > 0 then
    			g_XOppState = -1;
    		elseif (t_OppPos.X + (g_PaddleSize / 2) - t_BallPos.X + (g_BallSize / 2)) < 0 then
    			g_XOppState = 1;
    		else
    			g_XOppState = 0;
    		end
    	end
    end
    I suspect that my example is not exactly what you are trying to accomplish (you're probably working on something more productive ) , but I think the concept would be the same.
    Last edited by TJS; 02-08-2006 at 09:19 AM.

Similar Threads

  1. html page and link
    By mountain07 in forum AutoPlay Media Studio 6.0
    Replies: 1
    Last Post: 11-19-2005, 09:00 PM
  2. Example: Loading Paragraph Text Using a Timer
    By Jonas DK in forum AutoPlay Media Studio 5.0 Examples
    Replies: 7
    Last Post: 11-25-2004, 05:10 PM
  3. Using Timer Events
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 09-22-2003, 02:14 PM
  4. Replies: 14
    Last Post: 06-24-2003, 04:21 AM
  5. HOWTO: Create a Page Template
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-26-2002, 05:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts