File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ namespace SharpEngine.Core.Utils;
77/// </summary>
88/// <param name="startTime">Time of Timer</param>
99/// <param name="endFunction">Function which be called at the end</param>
10- public class Timer ( float startTime , Action endFunction )
10+ /// <param name="loop">True if timer will loop</param>
11+ public class Timer ( float startTime , Action endFunction , bool loop = false )
1112{
1213 /// <summary>
1314 /// Start Time of Timer
@@ -24,6 +25,11 @@ public class Timer(float startTime, Action endFunction)
2425 /// </summary>
2526 public Action EndFunction { get ; set ; } = endFunction ;
2627
28+ /// <summary>
29+ /// True if timer will loop
30+ /// </summary>
31+ public bool Loop { get ; set ; } = loop ;
32+
2733 /// <summary>
2834 /// Update Timer with Time
2935 /// </summary>
@@ -35,7 +41,10 @@ public bool Update(float delta)
3541 if ( CurrentTime <= 0 )
3642 {
3743 EndFunction ( ) ;
38- return true ;
44+ if ( Loop )
45+ CurrentTime = StartTime ;
46+ else
47+ return true ;
3948 }
4049
4150 return false ;
You can’t perform that action at this time.
0 commit comments