@@ -5,6 +5,7 @@ import flixel.FlxCamera;
5
5
import flixel .FlxG ;
6
6
import flixel .util .FlxAxes ;
7
7
import flixel .util .FlxColor ;
8
+ import flixel .util .FlxSignal .FlxTypedSignal ;
8
9
9
10
class CameraFrontEnd
10
11
{
@@ -19,6 +20,12 @@ class CameraFrontEnd
19
20
*/
20
21
public var bgColor (get , set ): FlxColor ;
21
22
23
+ public var cameraAdded (default , null ): FlxTypedSignal <FlxCamera -> Void > = new FlxTypedSignal <FlxCamera -> Void >();
24
+
25
+ public var cameraRemoved (default , null ): FlxTypedSignal <FlxCamera -> Void > = new FlxTypedSignal <FlxCamera -> Void >();
26
+
27
+ public var cameraResized (default , null ): FlxTypedSignal <FlxCamera -> Void > = new FlxTypedSignal <FlxCamera -> Void >();
28
+
22
29
/**
23
30
* Allows you to possibly slightly optimize the rendering process IF
24
31
* you are not doing any pre-processing in your game state's draw() call.
@@ -41,6 +48,7 @@ class CameraFrontEnd
41
48
FlxG .game .addChildAt (NewCamera .flashSprite , FlxG .game .getChildIndex (FlxG .game ._inputContainer ));
42
49
FlxG .cameras .list .push (NewCamera );
43
50
NewCamera .ID = FlxG .cameras .list .length - 1 ;
51
+ cameraAdded .dispatch (NewCamera );
44
52
return NewCamera ;
45
53
}
46
54
@@ -53,14 +61,15 @@ class CameraFrontEnd
53
61
public function remove (Camera : FlxCamera , Destroy : Bool = true ): Void
54
62
{
55
63
var index : Int = list .indexOf (Camera );
56
- if (( Camera != null ) && index != - 1 )
64
+ if (Camera != null && index != - 1 )
57
65
{
58
66
FlxG .game .removeChild (Camera .flashSprite );
59
67
list .splice (index , 1 );
60
68
}
61
69
else
62
70
{
63
- FlxG .log .warn (" FlxG.cameras.remove(): The camera you attemped to remove is not a part of the game." );
71
+ FlxG .log .warn (" FlxG.cameras.remove(): The camera you attempted to remove is not a part of the game." );
72
+ return ;
64
73
}
65
74
66
75
if (FlxG .renderTile )
@@ -72,9 +81,9 @@ class CameraFrontEnd
72
81
}
73
82
74
83
if (Destroy )
75
- {
76
84
Camera .destroy ();
77
- }
85
+
86
+ cameraRemoved .dispatch (Camera );
78
87
}
79
88
80
89
/**
@@ -86,17 +95,12 @@ class CameraFrontEnd
86
95
public function reset (? NewCamera : FlxCamera ): Void
87
96
{
88
97
for (camera in list )
89
- {
90
- FlxG .game .removeChild (camera .flashSprite );
91
- camera .destroy ();
92
- }
98
+ remove (camera );
93
99
94
100
list .splice (0 , list .length );
95
101
96
102
if (NewCamera == null )
97
- {
98
103
NewCamera = new FlxCamera (0 , 0 , FlxG .width , FlxG .height );
99
- }
100
104
101
105
FlxG .camera = add (NewCamera );
102
106
NewCamera .ID = 0 ;
0 commit comments