Revision | 35 (tree) |
---|---|
Time | 2009-02-26 21:01:40 |
Author | karasimiso |
Faceオブジェクトをプールするためのメソッド準備
@@ -24,12 +24,12 @@ | ||
24 | 24 | |
25 | 25 | #include "Face.h" |
26 | 26 | #include "Window.h" |
27 | +#include "GC.h" | |
27 | 28 | |
28 | 29 | Face::Face() |
29 | 30 | { |
30 | 31 | waitingForSurface = false; |
31 | 32 | inactive = false; |
32 | - destroy = false; | |
33 | 33 | alpha = SDL_ALPHA_OPAQUE; |
34 | 34 | alphaFlags = SDL_SRCALPHA; |
35 | 35 | layer = Window::DEFAULTLAYER; |
@@ -36,3 +36,13 @@ | ||
36 | 36 | surface = NULL; |
37 | 37 | initFrame(); |
38 | 38 | } |
39 | + | |
40 | +Face* Face::create() | |
41 | +{ | |
42 | + return GC<Face>::getInstance(); | |
43 | +} | |
44 | + | |
45 | +void Face::destroy() | |
46 | +{ | |
47 | + GC<Face>::destroy(this); | |
48 | +} |
@@ -66,7 +66,6 @@ | ||
66 | 66 | { |
67 | 67 | face->inactive = false; |
68 | 68 | face->waitingForSurface = false; |
69 | - face->destroy = false; | |
70 | 69 | } |
71 | 70 | |
72 | 71 | bool ActionFO::action(SceneMediator* mediator) { |
@@ -173,7 +172,6 @@ | ||
173 | 172 | obj->width = width; |
174 | 173 | obj->height = height; |
175 | 174 | |
176 | - obj->face = new Face(); | |
177 | 175 | obj->face->setSurface(face->surface); |
178 | 176 | obj->face->initFrame(face->frameWidth, face->frameHeight, face->frameInterval); |
179 | 177 | obj->face->setDistRect(x,y); |
@@ -51,7 +51,6 @@ | ||
51 | 51 | SDL_Surface* surface; |
52 | 52 | bool waitingForSurface; |
53 | 53 | bool inactive; |
54 | - bool destroy; | |
55 | 54 | |
56 | 55 | Face(); |
57 | 56 |
@@ -58,6 +57,9 @@ | ||
58 | 57 | private: |
59 | 58 | List<Face>::Item* listIndex; |
60 | 59 | public: |
60 | + Face* create(); | |
61 | + void destroy(); | |
62 | + | |
61 | 63 | inline List<Face>::Item* getListIndex() |
62 | 64 | { |
63 | 65 | return listIndex; |
@@ -97,10 +97,6 @@ | ||
97 | 97 | if ( face->waitingForSurface ) { |
98 | 98 | f = f->getNext(); |
99 | 99 | } |
100 | - else if ( face->destroy ) { | |
101 | - delete (face); | |
102 | - f = faces->erase(f); | |
103 | - } | |
104 | 100 | else if ( face->surface == NULL || face->inactive ) { |
105 | 101 | f = faces->erase(f); |
106 | 102 | } |