B4J Library jAnimation

I was reading about animation using JavaFX, and stumbled across a blog which explained it quite nicely.

I wrote the jAnimation library to see if it was possible to use animation from B4J, obviously it was or else I would not have posted this.

Two things about the library :
1, It exposes loads of methods and fields, which I frankly don't understand (more reading required).
2, It only works (the demo I have included) in RELEASE mode, if run under Debug mode, you get one frame per run.


I have included the source for the library, just in case someone spots something I missed and can improve upon it.

The web address for the picture I used is in the B4J source, that way you wont have to calculate the offsets etc if you use the same one for testing.

Latest version now 1.10 for library
Added Transitions - can now move items on a path, make them fade etc.
AnimationTest shows how to call the new routines.
Again source code for library included.

New Version 1.15
use in conjunction with simpleGame , just a demo to show what can be done with the new functions etc
I have included the image file for the paper plane in the project zip.
I drew the picture, as you see I am no artist, but it could be an animated bird for example flying around.
Working on documenting the library now.
Enjoy
 

Attachments

  • AnimationTest.zip
    1.9 KB · Views: 639
  • jAnimationLibrary.zip
    9.1 KB · Views: 538
  • simpleGame.zip
    2.6 KB · Views: 615
  • jAnimationLibraryV1.15.zip
    7.3 KB · Views: 650
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Hi Daestrum,
How to make it animate? I get only the picture.
 

Attachments

  • Myresult.png
    Myresult.png
    68 KB · Views: 566

Daestrum

Expert
Licensed User
Longtime User
When you downloaded the picture, did you get the original sized one? That is what the offsets and sizes are based on.

Only getting a single frame, that is what happened to me when I ran the project in debug mode. It needs to run in release mode.

This is what I see when I run it (attached screenshot)
 

Attachments

  • java 2013-12-29 10-52-05-78.png
    java 2013-12-29 10-52-05-78.png
    77.7 KB · Views: 457
Last edited:

Daestrum

Expert
Licensed User
Longtime User
I found a way to be able to see the animation in Debug mode, not elegant but it does allow you to step through the animation to be able to check positioning and offsets etc.

get scenebuilder to add mouseclick handler then add

B4X:
Sub image1_MouseClicked (EventData As MouseEvent)
    If animationPlaying Then
        ani.pause()
        animationPlaying = False
    Else
        ani.play()
        animationPlaying = True
    End If
End Sub

and dim a flag (in this case aniimationPlaying) as boolean (default=false).
now it will step through the animation even in debug mode.

In release mode it will pause and resume on mouse click on the animation.
 

Daestrum

Expert
Licensed User
Longtime User
New version of library and AnimationTest in post #1, even more functions working for animation and transitions. (paths cubiccurves etc)
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Hi Daestrum,
After I download a new one,I have error this.
 

Attachments

  • error.png
    error.png
    17.1 KB · Views: 404

Daestrum

Expert
Licensed User
Longtime User
I tried mine and do not get that error. Here is a copy of my b4j project.
I don't think I changed anything since uploading the previous one other than adding a checkbox.
 

Attachments

  • AnimationTest.zip
    1.9 KB · Views: 371

magoandroid

Member
Licensed User
Longtime User
Hi Daestrum,
After I download a new one,I have error this.


Hi Theera,
as you can see in the attached picture works for me.

I have created your error, using the lib 1.0, with the new code example Daestrum.

Maybe you forgot to update the "Additional Libraries" with lib v1.10


Greetings
Mago
 

Attachments

  • HorseAnimation2.png
    HorseAnimation2.png
    282.6 KB · Views: 422

Daestrum

Expert
Licensed User
Longtime User
new version 1.15 in post #1
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi magoandroid,
I don't forget update,and I 've refreshed it already,but I 've error. Thank you,your replies. I will do following as Daestrum's new version again.
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi Daestrum,
After I do as Magoandroid's guide (Using only 1 frame), I see only the picture's blink,Is right?
P.S. Test @ version 1.10
 

Attachments

  • Right.png
    Right.png
    22 KB · Views: 414
Top