Thread: Playing an image sequence in reverse
Status: Alpha
Brought to you by:
cwalther
From: James W. <jfc...@ya...> - 2009-09-11 17:49:10
|
Hi all, I'm trying to run a JPEG image sequence in reverse order, but am running into problems: Code: cubic { "dummy1024.png", "dummy.png","dummy.png", "dummy.png", "dummy.png", "dummy.png" } local anim = patch {face=1, x = 0, y = 0, image = "patches/anim_100.jpg" } local animpos = 100 hotspotmap "hotspotmap.png" hotspot { onmousedown = function() pipmak.schedule( 0.04, function() animpos = math.mod(animpos - 1, 101) anim:setimage ("patches/anim_" .. animpos .. ".jpg") return 0.04 end ) end } This playes it backward, but once it gets to frame "anim_0.jpg", it goes on to output continusly "Cannot find file "anim_-1.jpg" Cannot find file "anim_-2.jpg", and so on. How do I make it loop? Thanks, James |
From: Urs H. <ur...@an...> - 2009-09-27 09:59:35
|
Hi > I'm trying to run a JPEG image sequence in reverse order, but am > running into problems: > > Code: > [...] > animpos = math.mod(animpos - 1, 101) > [...] I guess this line is the problem. According to the Lua 5.0 reference, math.mod just uses the mod operator from ANSI C. If I remember correctly, ANSI C does define the result of it on a negative number as implementation specific, so, depending on the plattform the software runs on, math.mod(-1, 101) could be -1 or 100. By replacing the above line with if animpos < 0 then animpos = 100 end should give what you want. However, because of laziness, I have not tested it! Greetings Urs |
From: James W. <jfc...@ya...> - 2009-09-28 20:22:58
|
Thanks! However, I still got the same output when I used this, Pipmak tried to find "an_anim_-1" and so on. Here's my new code: CODE***************************************************************** cubic { "dummy1024.png", "dummy.png","dummy.png", "dummy.png", "dummy.png", "dummy.png" } local an_linkingBook = patch {face=1, x = 0, y = 0, image = "an_linkingBook/an_linkingBook_0.jpg" } local animpos = 100 hotspotmap "hotspotmap.png" hotspot { onmousedown = function() if animpos == 0 then animpos = 100 else pipmak.schedule( 0.04, function() animpos = math.mod(animpos - 1, 100) an_linkingBook:setimage ("an_linkingBook/an_linkingBook_" .. animpos .. ".jpg") return 0.04 end ) end end } CODE***************************************************************** Does anyone see the problem? I sure can't. Thanks, James --- On Sun, 9/27/09, Urs Holzer <ur...@an...> wrote: From: Urs Holzer <ur...@an...> Subject: Re: Playing an image sequence in reverse To: pip...@li... Date: Sunday, September 27, 2009, 5:59 AM Hi > I'm trying to run a JPEG image sequence in reverse order, but am > running into problems: > > Code: > [...] > animpos = math.mod(animpos - 1, 101) > [...] I guess this line is the problem. According to the Lua 5.0 reference, math.mod just uses the mod operator from ANSI C. If I remember correctly, ANSI C does define the result of it on a negative number as implementation specific, so, depending on the plattform the software runs on, math.mod(-1, 101) could be -1 or 100. By replacing the above line with if animpos < 0 then animpos = 100 end should give what you want. However, because of laziness, I have not tested it! Greetings Urs ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Pipmak-Users mailing list Pip...@li... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |
From: Urs H. <ur...@an...> - 2009-09-30 14:36:17
|
James Wilson wrote: > However, I still got the same output when I used this, Pipmak tried to > find "an_anim_-1" and so on. pipmak.schedule runs the function you give it as an argument after the given time. So, what is run again and again is only the function() below, not the whole code of onmousedown of the hotspot. So the if..then I gave you in my previous post has to be placed in the function() below: > pipmak.schedule( > 0.04, > function() > animpos = math.mod(animpos - 1, 100) > an_linkingBook:setimage ("an_linkingBook/an_linkingBook_" .. animpos .. > ".jpg") return 0.04 > end > ) Just change this to pipmak.schedule( 0.04, function() if animpos < 0 then animpos = 100 end an_linkingBook:setimage ("an_linkingBook/an_linkingBook_" .. animpos ..".jpg") return 0.04 end ) or similar. Now it loops automatically. I hope this is what you want. Then you also don't need the if..then..else in the onmousedown function. Greetings Urs |
From: James W. <jfc...@ya...> - 2009-10-01 05:36:57
|
Thanks, I think this last little problem is my fault: I click on the hotspot and nothing happens. I think it's because I closed "hotspot" incorrectly. What do you think? Sorry to drag this out. CODE************************ hotspot { onmousedown = function() pipmak.schedule( 0.04, function() if animpos < 0 then animpos = 100 end an_linkingBook:setimage ("an_linkingBook/an_linkingBook_" .. animpos ..".jpg") return 0.04 end ) end } END CODE******************** Thanks, James --- On Wed, 9/30/09, Urs Holzer <ur...@an...> wrote: From: Urs Holzer <ur...@an...> Subject: Re: Playing an image sequence in reverse To: pip...@li... Date: Wednesday, September 30, 2009, 9:33 AM James Wilson wrote: > However, I still got the same output when I used this, Pipmak tried to > find "an_anim_-1" and so on. pipmak.schedule runs the function you give it as an argument after the given time. So, what is run again and again is only the function() below, not the whole code of onmousedown of the hotspot. So the if..then I gave you in my previous post has to be placed in the function() below: > pipmak.schedule( > 0.04, > function() > animpos = math.mod(animpos - 1, 100) > an_linkingBook:setimage ("an_linkingBook/an_linkingBook_" .. animpos .. > ".jpg") return 0.04 > end > ) Just change this to pipmak.schedule( 0.04, function() if animpos < 0 then animpos = 100 end an_linkingBook:setimage ("an_linkingBook/an_linkingBook_" .. animpos ..".jpg") return 0.04 end ) or similar. Now it loops automatically. I hope this is what you want. Then you also don't need the if..then..else in the onmousedown function. Greetings Urs ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Pipmak-Users mailing list Pip...@li... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |
From: Urs H. <ur...@an...> - 2009-10-01 10:47:10
|
James Wilson wrote: > Thanks, I think this last little problem is my fault: > I click on the hotspot and nothing happens. I think it's because I closed > "hotspot" incorrectly. What do you think? Sorry to drag this out. Sorry, this is my fault. The line if animpos < 0 then animpos = 100 end only makes sure that animpos gets back to 100 once it reaches -1. I forgot to insert a line that actually decreases animpos by 1. So this should work now: hotspot { onmousedown = function() pipmak.schedule( 0.04, function() animpos = animpos - 1 if animpos < 0 then animpos = 100 end an_linkingBook:setimage ("an_linkingBook/an_linkingBook_" .. animpos ..".jpg") return 0.04 end ) end } |
From: James W. <jfc...@ya...> - 2009-10-01 14:34:49
|
Thanks! That worked perfectly. Thanks also for being patient with me. Thanks again, James --- On Thu, 10/1/09, Urs Holzer <ur...@an...> wrote: From: Urs Holzer <ur...@an...> Subject: Re: Playing an image sequence in reverse To: pip...@li... Date: Thursday, October 1, 2009, 6:47 AM James Wilson wrote: > Thanks, I think this last little problem is my fault: > I click on the hotspot and nothing happens. I think it's because I closed > "hotspot" incorrectly. What do you think? Sorry to drag this out. Sorry, this is my fault. The line if animpos < 0 then animpos = 100 end only makes sure that animpos gets back to 100 once it reaches -1. I forgot to insert a line that actually decreases animpos by 1. So this should work now: hotspot { onmousedown = function() pipmak.schedule( 0.04, function() animpos = animpos - 1 if animpos < 0 then animpos = 100 end an_linkingBook:setimage ("an_linkingBook/an_linkingBook_" .. animpos ..".jpg") return 0.04 end ) end } ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Pipmak-Users mailing list Pip...@li... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Urs H. <ur...@an...> - 2009-10-02 19:07:33
|
James Wilson wrote: > Thanks! That worked perfectly. Thanks also for being patient with me. Good. By the way, if you activate the animation like that, then you have to make sure that it is not activated twice. Try clicking multiple times at the image to see what happens. If my guess is correct, the sequence will run twice as fast (if your computer can keep up with the pace) after you click on it the second time. In other words: You have to make sure that the animation can not be activated again while it is already running. However, if I remember correctly, the animation in linking books in Myst starts immediately after opening the book. In other words, the animation is activated automatically and not by the user. If the same is true for your linking books, you don't have the problem I described above. And anyway, don't hesitate to ask more questions. We are happy to answer them. Greetings Urs |