No timers does save time... a lot!
Hi,
To bring up an old subject. I am working on a project and in the menu I had lots of timers.
Yesterday I worked all day to get them out and replace them by either self.time or interpolate selfmade time attributes. I thought it would only win me processor time but the decrease of loading time is incredible.
IBefore the menu there is an intro and when I had timers and went from intro to menu it took about 7 seconds at least.
Now without the timers it takes about 2 seconds. Awesome!
So for the ones with doubts, I believe no timers is the way to go!
To bring up an old subject. I am working on a project and in the menu I had lots of timers.
Yesterday I worked all day to get them out and replace them by either self.time or interpolate selfmade time attributes. I thought it would only win me processor time but the decrease of loading time is incredible.
IBefore the menu there is an intro and when I had timers and went from intro to menu it took about 7 seconds at least.
Now without the timers it takes about 2 seconds. Awesome!
So for the ones with doubts, I believe no timers is the way to go!
Comments
thanks kipper
After 0.2 sec timer:
Make a (self) attribute named timer
Interpolate
self.timer to 1
Duration 0.2
Rule
when atribute self.timer = 1
[do something]
interpolate self.timer to 1
Duration 0.001 [as small as posible, 0 doesn't work because it sometimes crashes]
Instead of an after x seconds timer in the beginning of a scene you can use a rule:
Rule
when attribute self.time = x
[do something]
or
Rule
when attribute self.time > x
do something
Every 1 second timer:
Make a timer attribute
Rule
when timer = 1
interpolate timer to 0
Duration 0.001 second
otherwise
interpolate timer to 1
duration 1 second
Rule
when self.time = 1
do something
Sometimes self.time = 1 in the 'every' time is not triggering (probably because self.time is 1 for a very short time). You can also use when self.time > 0.5 because self.time is > 0.5 for a longer time then it is 1.
Hope this makes sense.
Cheers!
Lump Apps and My Assets
When you would use change to get back to the initial timer value in the "when timer = 1" rule the interpolate value to 1 wasn't finished when it was 1. So the change attribute would change it to 0 and the interpolate would change it back to 1 although the interpolate should already have stopped when the value was 1.
That is why I interpolate back to 0 instead of change. While the initial interpolate might not be ready the second will always change it to 0.
Hope this makes sense
Lump Apps and My Assets
Do you need to use interpolate at all? I suppose it depends on the context but when I had a lot of moving objects on the screen I found additional interpolates (of colour,size etc) tended to punch the frame rate in the face.
Have you tried the following?
Create a real attribute game.timeStamp
Create a real or index attribute game.duration with your chosen period of seconds. In this example 2.
Create an index attribute called zero with value 0
To replace an 'after' timer:
RULE
When your event happens
Change game.timeStamp to game.time
RULE
When game.time is more than/equal to game.timeStamp + game.duration
... do yo' thang
To replace a 'for' timer:
RULE
When your event happens
Change game.timeStamp to game.time
RULE
When game.time is less than/equal to time.stamp + game.duration
… do the hockey pockey
To replace an 'every' timer:
(every 2 seconds)
RULE
When game.zero = game.time%2
... do the Bart (man)
(every 1 second)
RULE
When game.zero = (game.time*2)%2
... do the right thing
(every 0.5 seconds)
RULE
When game.zero = (game.time*4)%2
... do what you do best
Shaz
------------
"...the resulting sonic effect is almost mesmerising." Pocket Gamer
Sound design and music service available: http://tiny.cc/MusicService
www.HoneyTribeStudios.com
In my current game I have not a lot of moving objects so I don't have a frame rate problem (it is around 60 most of the time anyway).
Because my method uses only one attribute it was easier to implement (and I am a bit lazy sometimes) but I see a lot of advantages in yours.
Thanks for sharing!
Cheers,
Ludwig
Lump Apps and My Assets
can't think what the benefit would be... just throwing it out there...
you could use a similar setup to my loading times timer...its a bit annoying to use in that the seconds loop when they hit 60 so you have to track if the minutes change and do any offset...(same for milli seconds and seconds etc)
kipper
its still in beta.
Loading times will improve..
In app purchasing is coming.
Android support too..
Things are bright... and still no complicated coding...just far less complicated maths and rules instead.
Have to figure out how but If the seconds are 60 every 60 seconds (makes sense) then you could use this when used with a modulator for avery value below 60 seconds...
Sorry if thats wrong, I have just recently discovered how the math I learned in school works
Lump Apps and My Assets
yeah...you could have rules
For every second:
if device, clock, milli seconds = 1 (or you could use any number between 0 and 999)
then do something
for every ten seconds
if any:
device, clock, seconds = 0
device, clock, seconds = 10
device, clock, seconds = 20
device, clock, seconds = 30
device, clock, seconds = 40
device, clock, seconds = 50
device, clock, seconds = 60
If game.clk is an attribute with value 3 then Help! will flash up every 3 seconds.
Lump Apps and My Assets
Unless I've misunderstood your question?
The technique I posted above does not include something that duplicates the 'run to completion' check box in timer behaviours.
Generally it's better to use attributes. This will probably save you time as you develop you game.
Rather than clicking through all the actors when you want to make changes it's much quicker to have a list of attributes on the same page that you can change quickly.
e.g you might have a set of actors that move at the same speed, or have the same initial hit points or whatever.
You'll probably be adjusting those figures as you develop the game, finding out which values make the game feel right.
If you have to double click every actor and every instance of an actor, find the values and change them one by one - that takes longer. Especially as a game gets bigger and more complex.
Shaz
------------
"...the resulting sonic effect is almost mesmerising." Pocket Gamer
Sound design and music service available: http://tiny.cc/MusicService
www.HoneyTribeStudios.com
If you're using small increments of time wrap the equation in a floor function otherwise it might not work properly.
So for 0.1 seconds
when game.zero = floor((game.time*20)%2)
... HEEEEY Macarena!