Totally Loopy

Mike Bonner bonnmike at gmail.com
Fri Jul 17 15:47:29 CEST 2015


You could also use a send loop and keep track of which image is currently
visible, switch to the next frame, loop again.  And then use "the keysdown"
within the loop itself to check for the arrow keys. (As I did in the other
animation you asked about)

Off the top of my head, something like..

on animaSHun
-- sCounter would have been initialized to 1
switch sCounter
case 1
   set the vis of img "M1" to true
   set the vis of img "M4" to false
   put 2 into sCounter
   break

case 2
    set the vis of img "M2" to true
   set the vis of img "M1" to false
   put 3 into sCounter
   break
case 3
    set the vis of img "M3" to true
   set the vis of img "M2" to false
   put 4 into sCounter
   break
case 4
   set the vis of img "M4" to true
   set the vis of img "M3" to false
   put 1 into sCounter
   break
end switch
if the keysdown is not empty then
   if "65361" is among the items of the keysdown then
      -- the code for the left arrow key
   end if
   if "65363" is among the items of the keysdown then
        -- the code for the right arrow key
   end if
end if
send "animaSHun" to me in 4 ticks
end animaSHun


You could of course then break things into smaller chunks to make
management of code easier. (you can still do this, loop method doesn't
really matter, rather than send you could put a single wait with messages
in there for the same effect, then directly call the handler again)

on animaSHun
   animateIt -- the hander to do the animaSHun
   processKeys -- the handler to ... handle the keysdown
   send "animaSHun" to me in 4 ticks
end animaSHun


On Fri, Jul 17, 2015 at 5:52 AM, David Williams <dwilliams at livecode.com>
wrote:

> Disregard that - as soon as I hit send, my mail client fetched the other
> responses :)
>
>
> On Fri, 17 Jul 2015 12:46:45 +0100, David Williams <dwilliams at livecode.com>
> wrote:
>
>  Hi Richmond,
>>
>> The way to do this is to wait with messages - so 'wait 4 ticks' becomes
>> 'wait 4 ticks with messages'. This form of the command allows other
>> messages to be passed while it's executing, making it a non-blocking wait.
>>
>> Regards,
>>
>> -David
>>
>> On Fri, 17 Jul 2015 11:52:06 +0100, Richmond <richmondmathewson at gmail.com>
>> wrote:
>>
>>  I am animating a series of images like this:
>>>
>>> on animaSHun
>>>     set the vis of img "M1" to true
>>>     set the vis of img "M4" to false
>>>     wait 4 ticks
>>>      set the vis of img "M2" to true
>>>     set the vis of img "M1" to false
>>>     wait 4 ticks
>>>      set the vis of img "M3" to true
>>>     set the vis of img "M2" to false
>>>     wait 4 ticks
>>>     set the vis of img "M4" to true
>>>     set the vis of img "M3" to false
>>>     wait 4 ticks
>>>     animaSHun
>>> end animaSHun
>>>
>>> and there I was feeling proud of myself for having been "so" clever, BUT
>>> I was wrong . . .
>>>
>>> Now in the same cardScript I have an "on arrowKey" script to let me move
>>> the animation
>>> around the card with the arrow keys on my keyboard . . .
>>>
>>> But that "animaSHun" routine goes round and round (as, indeed, it
>>> should) and the arrowKeys
>>> are quite unable to "get a word in edgeways"; in fact the only way to
>>> stop the thing
>>> is by crashing LiveCode.
>>>
>>> I would be grateful if anyone could tell me how to get a word in
>>> edgeways while keeping the animation going.
>>>
>>> Yup: I know I could just use an animated GIF image . . . but, call me
>>> bloody-minded, I have my
>>> reasons for not using one.
>>>
>>> Richmond.
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>
>>
>>
>
> --
> Using Opera's mail client: http://www.opera.com/mail/
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


More information about the use-livecode mailing list