Animation
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Animation
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
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.
Re: Animation
What is 'buttonSelected'?
This might work:
Code: Select all
if gAnimation = "false" then exit buttonSelected
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
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation
Dunno: seems complicated.
I would just glue the sequence of PNG images together with the sound file into a movie
and play that.
I would just glue the sequence of PNG images together with the sound file into a movie
and play that.
Re: Animation
Thanks Jimi. exit buttonSelected was a copy/paste error. It is exit playAnimation.
Re: Animation
richmond62, using video files was how I wanted to manage this. I couldn't get a decent playback on the iOS devices.
Re: Animation
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.
Re: Animation
I added this and had the loop repeat until gAnimation - "false"
on soundFinishedOnChannel pChannel, pSound
put "false" into gAnimation
end soundFinishedOnChannel
on soundFinishedOnChannel pChannel, pSound
put "false" into gAnimation
end soundFinishedOnChannel
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation
Well, that would involve a lot of fiddling around with export formats, probably with Quicktime Pro.I couldn't get a decent playback
Re: Animation
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
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
Re: Animation
@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!
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation
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/
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/