Animation

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
chelling
Posts: 100
Joined: Tue Mar 06, 2007 3:14 am

Animation

Post by chelling » Sat Sep 08, 2018 9:43 pm

I am trying to play an animation (series of png's) that is correlated with a sound file. This works to play the sound file, and I can exit the animation and stop the sound from playing when gAnimation = "false". The animation continues after the sound is finished. What am I missing? I think this line is the problem: repeat until soundFinishedOnChannel, "current", tSoundFile Thanks!

on playAnimation
if gAnimation = "true" then
set the layerMode of card button "animeBtn" to "dynamic"
repeat with n = 1 to 2
put "robot_" & n into tName
set the icon of card button "animeBtn" to tName
wait 1 with messages
if gAnimation = "false" then exit playAnimation
end repeat
put specialFolderPath("engine") & "/audio/robotEffect.mp3" into tSoundFile
if the environment is "mobile" then mobilePlaySoundOnChannel tSoundFile, "current", "now"
repeat until soundFinishedOnChannel, "current", tSoundFile
repeat with n = 3 to 72
put "robot_" & n into tName
set the icon of card button "animeBtn" to tName
wait 1 with messages
if gAnimation = "false" then exit playAnimation
if soundFinishedOnChannel, "current", tSoundFile then exit repeat
end repeat
end repeat
end if
set the icon of card button "animeBtn" to 1485
set the icon of card button "SwitchButton" to 1140
set the layerMode of card button "animeBtn" to "static"
end playAnimation
Last edited by chelling on Sat Sep 08, 2018 10:36 pm, edited 1 time in total.

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Animation

Post by jiml » Sat Sep 08, 2018 10:10 pm

What is 'buttonSelected'?

Code: Select all

if gAnimation = "false" then exit buttonSelected
This might work:

Code: Select all

on playAnimation
   if gAnimation = "true" then
      set the layerMode of card button "animeBtn" to "dynamic"
      repeat with n = 1 to 2
         put "robot_" & n into tName
         set the icon of card button "animeBtn" to tName
         wait 1 with messages
         if gAnimation = "false" then exit buttonSelected --ERROR HERE!!!
      end repeat
      put specialFolderPath("engine") & "/audio/robotEffect.mp3" into tSoundFile
      if the environment is "mobile" then mobilePlaySoundOnChannel tSoundFile, "current", "now"
      repeat until gAnimation = "false"
               -- YOU MAY NEED TO STOP PLAYING SOUND HERE
         repeat with n = 3 to 72
            if soundFinishedOnChannel, "current", tSoundFile then 
               put "false" into gAnimation
               exit repeat
            end if          
            put "robot_" & n into tName
            set the icon of card button "animeBtn" to tName
            wait 1 with messages
         end repeat
      end repeat
   end if
   set the icon of card button "animeBtn" to 1485
   set the icon of card button "SwitchButton" to 1140
   set the layerMode of card button "animeBtn" to "static"
end playAnimation

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Animation

Post by richmond62 » Sat Sep 08, 2018 10:13 pm

Dunno: seems complicated.

I would just glue the sequence of PNG images together with the sound file into a movie
and play that.

chelling
Posts: 100
Joined: Tue Mar 06, 2007 3:14 am

Re: Animation

Post by chelling » Sat Sep 08, 2018 10:14 pm

Thanks Jimi. exit buttonSelected was a copy/paste error. It is exit playAnimation.

chelling
Posts: 100
Joined: Tue Mar 06, 2007 3:14 am

Re: Animation

Post by chelling » Sat Sep 08, 2018 10:16 pm

richmond62, using video files was how I wanted to manage this. I couldn't get a decent playback on the iOS devices.

chelling
Posts: 100
Joined: Tue Mar 06, 2007 3:14 am

Re: Animation

Post by chelling » Sat Sep 08, 2018 10:41 pm

gAnimation is a flag that is set to stop the animation if the user needs to exit. I need the animation series to finish when the sound file is finished playing.

chelling
Posts: 100
Joined: Tue Mar 06, 2007 3:14 am

Re: Animation

Post by chelling » Sat Sep 08, 2018 11:26 pm

I added this and had the loop repeat until gAnimation - "false"

on soundFinishedOnChannel pChannel, pSound
put "false" into gAnimation
end soundFinishedOnChannel

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Animation

Post by richmond62 » Sun Sep 09, 2018 1:10 pm

I couldn't get a decent playback
Well, that would involve a lot of fiddling around with export formats, probably with Quicktime Pro.

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Animation

Post by capellan » Sun Sep 09, 2018 7:04 pm

Hi chelling,

Could you post a sample stack?
Probably there is a similar stack in revOnline,
the forums or the mail list.

http://livecodeshare.runrev.com/stack/857/Cel-Animation

Al

chelling
Posts: 100
Joined: Tue Mar 06, 2007 3:14 am

Re: Animation

Post by chelling » Fri Sep 14, 2018 4:12 pm

@capellan The stack is very large even at this beginning stage with all of the images I have been trying to work with. I have actually gone back to using videos....hoping I can make it work better. Thanks!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Animation

Post by richmond62 » Fri Sep 14, 2018 7:46 pm

I don't know what type of images you are using: JPEG, PNG, GIF ?

However, with a bit of effort one can shrink these formats to a level where they are considerably smaller than currently, yet acceptable to the human eye,

My "weapon of choice" is GIMP:

https://www.gimp.org/

Post Reply

Return to “iOS Deployment”