how can i make 2 timar :
ex: Page.StartTimer(5000); && Page.StartTimer(200);
in the same page, how??????????
Professional Software Development Tools
how can i make 2 timar :
ex: Page.StartTimer(5000); && Page.StartTimer(200);
in the same page, how??????????
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.![]()
sorry i can't understand , can u make a sample please
Here's an example that may help you out.
http://www.indigorose.com/forums/sho...2&postcount=19
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
FWIW it's fairly easy to create code based object timers with the existing system also.![]()
Object Timer ?? Wow... do we have it?Originally Posted by yosik
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
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.Originally Posted by Corey
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
Yes a separate "On Timer" event for every object would be handy for some stuff. You should add that to the suggestions forum.![]()
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).sorry i can't understand , can u make a sample please
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):
Now I set your preferred actions On Timer event for the page like moving the ball:Code:Page.StartTimer(10); g_OppDelay = 3;
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:-- Move the ball Image.SetPos("imgBall", t_BallPos.X + g_XBallMotion, t_BallPos.Y + g_YBallMotion);
I suspect that my example is not exactly (your probably working on something more productiveCode:-- 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) to what you are trying to accomplish, but I think the concept would be the same.
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).sorry i can't understand , can u make a sample please
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):
Now I set your preferred actions On Timer event for the page like moving the ball:Code:Page.StartTimer(10); g_OppDelay = 3;
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:-- Move the ball Image.SetPos("imgBall", t_BallPos.X + g_XBallMotion, t_BallPos.Y + g_YBallMotion);
I suspect that my example is not exactly what you are trying to accomplish (you're probably working on something more productiveCode:-- 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) , but I think the concept would be the same.
Last edited by TJS; 02-08-2006 at 09:19 AM.