usbong / UsbongKit

A framework for reading and displaying contents of Usbong Trees
www.usbong.ph
Apache License 2.0
2 stars 1 forks source link

Animation feature #29

Open masarapmabuhay opened 7 years ago

masarapmabuhay commented 7 years ago

Salut! The animation feature is now available in UsbongKit (Android), but not yet in UsbongKit (iOS). It would be wonderful if images can animate in the iOS version as well!

Here's the basic syntax that I used in the Android version.

<task-node name="animate_and_text~frame-0-3~@audioName=Page1~Ping-pong is a cooperative sport.">

1) animate_and_text means text is displayed below the animating image, like in imageTextDisplay.

ping-pong_content_english

2) frame-0-3 means the name of the image file begins with frame, and is numbered from 0 to 3, i.e. frame0, frame1, frame2, frame3. Of course, the frames can either be .png or .jpg.

After frame3, it loops back to frame0. Code-wise, I was able to implement this using the modulo (% sign), such as:

animate_counter = (animate_counter+1)%endFrame

I then put this in a thread separate from the Main thread.

If the person doesn't want the animation to loop, I'm thinking of adding the doNotLoopAnimation keyword like inserting optional in a component where the person is not required to enter a text, select an answer, etc.

The other variations of animate_text are: 1) text_and_animate, where text (scrollable) is displayed before the animating images, like in textImageDisplay. 2) animate, where only the animating images are shown, like in imageDisplay.

Please do feel free to express your opinion on these things.

Merci beaucoup toujours!