File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
Core/GDCore/Extensions/Builtin/SpriteExtension Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -583,7 +583,14 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
583583
584584 obj.AddExpression (" Sprite" ,
585585 _ (" Image" ),
586- _ (" Animation frame of the object" ),
586+ _ (" Current frame of the animation of the object" ),
587+ _ (" Animations and images" ),
588+ " res/actions/sprite.png" )
589+ .AddParameter (" object" , _ (" Object" ), " Sprite" );
590+
591+ obj.AddExpression (" AnimationFrameCount" ,
592+ _ (" Number of frames" ),
593+ _ (" Number of frames in the current animation of the object" ),
587594 _ (" Animations and images" ),
588595 " res/actions/sprite.png" )
589596 .AddParameter (" object" , _ (" Object" ), " Sprite" );
Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ SpriteExtension::SpriteExtension() {
108108 spriteExpressions[" Animation" ].SetFunctionName (" getAnimation" );
109109 spriteStrExpressions[" AnimationName" ].SetFunctionName (" getAnimationName" );
110110 spriteExpressions[" Sprite" ].SetFunctionName (" getAnimationFrame" );
111+ spriteExpressions[" AnimationFrameCount" ].SetFunctionName (" getAnimationFrameCount" );
111112 spriteExpressions[" AnimationSpeedScale" ].SetFunctionName (
112113 " getAnimationSpeedScale" );
113114 spriteExpressions[" ScaleX" ].SetFunctionName (" getScaleX" );
Original file line number Diff line number Diff line change @@ -754,6 +754,17 @@ namespace gdjs {
754754 return this . _currentFrame ;
755755 }
756756
757+ getAnimationFrameCount ( ) : number {
758+ if ( this . _currentAnimation >= this . _animations . length ) {
759+ return 0 ;
760+ }
761+ const currentAnimation = this . _animations [ this . _currentAnimation ] ;
762+ if ( this . _currentDirection >= currentAnimation . directions . length ) {
763+ return 0 ;
764+ }
765+ return currentAnimation . directions [ this . _currentDirection ] . frames . length ;
766+ }
767+
757768 /**
758769 * @deprecated
759770 * Return true if animation has ended.
You can’t perform that action at this time.
0 commit comments