File tree Expand file tree Collapse file tree 4 files changed +19
-4
lines changed
Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ class LfAudioManagerInternal {
248248 return false ;
249249 }
250250
251- LeafyDebug .log (" Ogg File Info: Rate=" + fileInfo .rate + " , Channels=" + fileInfo .channels , INFO );
251+ LeafyDebug .log (" Ogg File Info: Rate=" + fileInfo .rate + " , Channels=" + fileInfo .channels , DEBUG );
252252
253253 var needsReopen : Bool = false ;
254254 if (audioDevice <= 0 ) {
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ enum ObjectType {
3434enum CenterMode {
3535 CENTER_X ;
3636 CENTER_Y ;
37+ CENTER_XY ;
3738}
3839
3940/**
@@ -245,7 +246,7 @@ class LfObject extends LfBase {
245246 * Center the object in the screen
246247 * @param centerMode The mode to center the object
247248 */
248- public function center (? centerMode : CenterMode ): Void {
249+ public function center (? centerMode : CenterMode = CenterMode . CENTER_XY ): Void {
249250 if (this .width <= 0 || this .height <= 0 ) {
250251 LeafyDebug .log (" Object dimensions invalid before centering" , ERROR );
251252 return ;
@@ -256,9 +257,12 @@ class LfObject extends LfBase {
256257 this .x = Std .int ((Leafy .screenWidth - this .width ) / 2 );
257258 case CenterMode .CENTER_Y :
258259 this .y = Std .int ((Leafy .screenHeight - this .height ) / 2 );
259- default :
260+ case CenterMode . CENTER_XY :
260261 this .x = Std .int ((Leafy .screenWidth - this .width ) / 2 );
261262 this .y = Std .int ((Leafy .screenHeight - this .height ) / 2 );
263+ default :
264+ LeafyDebug .log (" Invalid center mode!" , ERROR );
265+ return ;
262266 }
263267 }
264268
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ class LfSprite extends LfObject {
8585 LeafyDebug .log (" Image must be a PNG file" , ERROR );
8686 return ;
8787 }
88- if (! LfSystemPaths .exists (correctPath ) ) {
88+ if (! LfSystemPaths .exists (correctPath )) {
8989 LeafyDebug .log (" Image path does not exist: " + imgPath , ERROR );
9090 return ;
9191 }
Original file line number Diff line number Diff line change @@ -92,6 +92,12 @@ class LfText extends LfObject {
9292 this .size = size ;
9393 this .fontPath = fontPath ;
9494
95+ // Set the default color to white
96+ this .sdlColor .r = 255 ;
97+ this .sdlColor .g = 255 ;
98+ this .sdlColor .b = 255 ;
99+ this .sdlColor .a = 255 ;
100+
95101 this .fontPtr = SDL_TTF . TTF_OpenFont (ConstCharPtr .fromString (correctPath ), size );
96102 if (untyped __cpp__ (" fontPtr == nullptr" )) {
97103 LeafyDebug .log (" Failed to load font: " + LfUtils .removeSDDirFromPath (fontPath ) + " with size: " + size , ERROR );
@@ -123,6 +129,11 @@ class LfText extends LfObject {
123129
124130 this .sdlRect .x = this .x ;
125131 this .sdlRect .y = this .y ;
132+
133+ if (this .width <= 0 || this .height <= 0 ) {
134+ LeafyDebug .log (" Invalid dimensions for text: " + text , ERROR );
135+ }
136+
126137 this .sdlRect .w = this .width ;
127138 this .sdlRect .h = this .height ;
128139
You can’t perform that action at this time.
0 commit comments