Animation observation Long introduction but quick question

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Animation observation Long introduction but quick question

Post by chris25 » Thu Dec 05, 2013 11:58 pm

Introduction: Due to overly complex coding and lack of experience I threw away all the code that is usually scripted in the Stack that involved frame rate and dispatching updates and updating screen (I think you know what I mean here without including the code) and all the code that I had written as it was causing so many problems for me in my inexperience. I therefore went back to the drawing board and looked for the simple methods and came up with this. I isloated each aspect of the animation and in a vacuum scripted individual movements with great success. Sub movement, mine dropping, intersect, and the troublesome explosion scenario works a treat (keeping it small to 3 images just for experimentation purposes). I put it together and it worked perfectly.

What I noticed was that the keysdown function would not work without that stack scripting. So I threw it away and did what you see here. Now, it also seems that the scripting in the UNCOMMENTED part of the dropmines also does not work without the stack scripting (referring to what I said above). The Commented line you see here is how I tested the intersect method. What now happens is that everytime I press the start button, the mine drops one pixel per mouseup click. I understand what is happening, but I do not understand why it is happening.

My question therefore is this: Do only certain types of scripting (animation wise) only work when there is a background loop in place such as is found in the well-known animation stack script involving screen updating and frame rates and dispatching updated screen information etc.

thankyou
chris

Code: Select all

on dropMines
   --move btn "mine1" from 176,93 to 176,191 without waiting
   set the top of btn "mine1" to the top of btn "mine1" + 1
   if the top of btn "mine1"  > the bottom of card "sendSurface" then
      set the loc of btn "mine1" to 327,0
      end if
end dropMines

Code: Select all

on startSequence
send "sub3" to me in 2 seconds
send "sub2" to me in 1200 milliseconds
send "sub1" to me in 600 milliseconds
end startSequence

on sub1
   set the icon of button "buttonsubbb" to the id of  img "blacksub1.png" 
end sub1

on sub2
   set the icon of button "buttonsubbb" to the id of  img "blacksub2.png" 
end sub2

on sub3
   set the icon of button "buttonsubbb" to the id of  img "blacksub3.png" 
end sub3

Code: Select all

on arrowkey pKey
   if pKey = "left" then
      set the left of button "buttonsubbb" to the left of button "buttonsubbb" -1
   end if
   if pKey = "right" then
      set the right of button "buttonsubbb" to the right of button "buttonsubbb" +1
   end if
   if pKey = "up" then
      move button "buttonsubbb" relative +1,-1
   end if
   if pKey = "down" then
      move button "buttonsubbb" relative +1,+1
   end if
end arrowkey

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Animation observation Long introduction but quick questi

Post by Simon » Fri Dec 06, 2013 12:05 am

Hi Chris,
That frame rate stuff would call dropMines every 30(?) ticks. I think that is part of your question.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: Animation observation Long introduction but quick questi

Post by chris25 » Fri Dec 06, 2013 12:13 am

Hallo there Simon, yes, it would call the dropmines in the previous way that I was doing it. So this kind of scripting then needs a background loop to be running in order for certain types of scripts to work then? No problem I am not going down that road, it fouls up the send messages that I have anyway. So now I understand why the mouseup (the start button) moves the mine one pixel at a time - ok I am getting it.
Chris

Post Reply