Moving Image within the card from right to left
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 9
- Joined: Thu Dec 18, 2014 10:17 am
Moving Image within the card from right to left
Hi,
Ive created a new challenge for myself. Im trying to move and Image from right to left within a card.
trying to create an effect of bouncing the image between the right and left edges of the card.
My code this far;
command preopencard
set location image "pinkwall" to 25,25
moveobjects
end preopencard
command moveobjects
// Move object down
--set the top of image "pinkwall" to the top of image "pinkwall" +1
//Reset object to top of page if moved of the page
--if the top of image "pinkwall" > the bottom of this card then
--set the bottom of image "pinkwall" to the top of this card
--end if
if the left of image "pinkwall" = the left of this card then
moveright
end if
if the right of image "pinkwall" = the right of this card then
moveleft
end if
send "moveobjects" to me in 50 milliseconds
end moveobjects
command moveright
set the right of image "pinkwall" to the right of image "pinkwall" +10
send "moveright" to me in 50 milliseconds
end moveright
command moveleft
set the left of image "pinkwall" to the left of image "pinkwall" -10
send "moveleft" to me in 50 milliseconds
end moveleft
regards
Lourinho81
Ive created a new challenge for myself. Im trying to move and Image from right to left within a card.
trying to create an effect of bouncing the image between the right and left edges of the card.
My code this far;
command preopencard
set location image "pinkwall" to 25,25
moveobjects
end preopencard
command moveobjects
// Move object down
--set the top of image "pinkwall" to the top of image "pinkwall" +1
//Reset object to top of page if moved of the page
--if the top of image "pinkwall" > the bottom of this card then
--set the bottom of image "pinkwall" to the top of this card
--end if
if the left of image "pinkwall" = the left of this card then
moveright
end if
if the right of image "pinkwall" = the right of this card then
moveleft
end if
send "moveobjects" to me in 50 milliseconds
end moveobjects
command moveright
set the right of image "pinkwall" to the right of image "pinkwall" +10
send "moveright" to me in 50 milliseconds
end moveright
command moveleft
set the left of image "pinkwall" to the left of image "pinkwall" -10
send "moveleft" to me in 50 milliseconds
end moveleft
regards
Lourinho81
Re: Moving Image within the card from right to left
Hi.
Oftentimes the order of the actions in your code can greatly affect the operation of that code. I just glanced at your handlers, and noticed that there was no way for each of the "move" handlers to switch to the other direction. Read your script carefully and see why this is so. Anyway, try this. I just made two buttons, one of which I named "bb". In the other button script:
Why the "optionKey" thingie? Write back, please, with what you find out.
Craig Newman
Oftentimes the order of the actions in your code can greatly affect the operation of that code. I just glanced at your handlers, and noticed that there was no way for each of the "move" handlers to switch to the other direction. Read your script carefully and see why this is so. Anyway, try this. I just made two buttons, one of which I named "bb". In the other button script:
Code: Select all
on mouseUp
set location btn "bb" to 25,225
if the left of btn "bb" <= the left of this card then moveright
else moveLeft
end mouseUp
command moveleft
if the optionKey is down then exit to top
set the left of btn "bb" to the left of btn "bb" - 10
if the left of btn"bb" <= the left of this card then moveRight
else send "moveleft" to me in 1
end moveleft
command moveRight
if the optionKey is down then exit to top
set the right of btn "bb" to the right of btn "bb" + 10
if the right of btn"bb" >= the right of this card then moveLeft
else send "moveRight" to me in 1
end moveRight
Craig Newman
Re: Moving Image within the card from right to left
Hi guys,
sloppiness might break your necks in future and less forgiving releases of LC
...
set THE loc OF image "pinkwall" to 25,25
...
set THE location OF btn "bb" to 25,225
...
Best
Klaus
sloppiness might break your necks in future and less forgiving releases of LC

...
set THE loc OF image "pinkwall" to 25,25
...
set THE location OF btn "bb" to 25,225
...
Best
Klaus
Re: Moving Image within the card from right to left
Not my fault. I never do that. Really. It was the other guy. Really,
Craig
Craig
-
- Livecode Opensource Backer
- Posts: 10100
- Joined: Fri Feb 19, 2010 10:17 am
Re: Moving Image within the card from right to left
I will investigate, Craig!dunbarx wrote:Not my fault. I never do that. Really. It was the other guy. Really,
Craig

-
- Posts: 9
- Joined: Thu Dec 18, 2014 10:17 am
Re: Moving Image within the card from right to left
Hi Guys,
Many thanks for your help and advise. I have managed to resolve the challenge with your assistance.
Updated Code below.
command preopencard
set location of image "pinkwall" to 225,25
moveobjects
moveleft
end preopencard
command moveobjects
// Move object down
set the top of image "pinkwall" to the top of image "pinkwall" +1
//Reset object to top of page if moved of the page
if the top of image "pinkwall" > the bottom of this card then
set the bottom of image "pinkwall" to the top of this card
end if
send "moveobjects" to me in 10 millisecond
end moveobjects
command moveleft
//Move Object Left else Right
set the left of image "pinkwall" to the left of image "pinkwall" -1
if the left of image "pinkwall" <= the left of this card then moveright
else send "moveleft" to me in 10 millisecond
end moveleft
command moveright
//Move Object Right else Left
set the right of image "pinkwall" to the right of image "pinkwall" +1
if the right of image "pinkwall" >= the right of this card then moveleft
else send "moveright" to me in 10 millisecond
end moveright
regards
Lourinho81
Many thanks for your help and advise. I have managed to resolve the challenge with your assistance.
Updated Code below.
command preopencard
set location of image "pinkwall" to 225,25
moveobjects
moveleft
end preopencard
command moveobjects
// Move object down
set the top of image "pinkwall" to the top of image "pinkwall" +1
//Reset object to top of page if moved of the page
if the top of image "pinkwall" > the bottom of this card then
set the bottom of image "pinkwall" to the top of this card
end if
send "moveobjects" to me in 10 millisecond
end moveobjects
command moveleft
//Move Object Left else Right
set the left of image "pinkwall" to the left of image "pinkwall" -1
if the left of image "pinkwall" <= the left of this card then moveright
else send "moveleft" to me in 10 millisecond
end moveleft
command moveright
//Move Object Right else Left
set the right of image "pinkwall" to the right of image "pinkwall" +1
if the right of image "pinkwall" >= the right of this card then moveleft
else send "moveright" to me in 10 millisecond
end moveright
regards
Lourinho81
-
- Posts: 32
- Joined: Fri Jan 16, 2015 5:31 pm
Re: Moving Image within the card from right to left
*bump*
While I appreciate treefolk pasting the script in here that is provided in the Game Academy, this thread is almost 3 years old (as is Game Academy) and updateScreen still isn't in the native LiveCode vocabulary. Any idea of a roadmap on this feature?
While I appreciate treefolk pasting the script in here that is provided in the Game Academy, this thread is almost 3 years old (as is Game Academy) and updateScreen still isn't in the native LiveCode vocabulary. Any idea of a roadmap on this feature?
Re: Moving Image within the card from right to left
Hi MWCoastMedia,
sorry, I really don't get it!?
"updatescreen" is just the name of a handler that is used in the "Game Academy" examples
which contains a lot of loc-setting and other game-relevant stuff.
BUT this is depending on the current situation resp. game and if you check the scripts of other games
you will see that every developer uses DIFFERENT commands in her/his "updatescreen" handler.
So what should a native "updatescreen" command do in Livecode in your opinion?
Best
Klaus
sorry, I really don't get it!?
"updatescreen" is just the name of a handler that is used in the "Game Academy" examples
which contains a lot of loc-setting and other game-relevant stuff.
BUT this is depending on the current situation resp. game and if you check the scripts of other games
you will see that every developer uses DIFFERENT commands in her/his "updatescreen" handler.
So what should a native "updatescreen" command do in Livecode in your opinion?

Best
Klaus
Re: Moving Image within the card from right to left
If I recall correctly, the Game Academy did include references to an updateScreen handler which took advantage of some of the "new" dynamic screen rendering features in the "then" update to LC. There was also mention of this updateScreen code being automagically included engine-side, the code provided was meant to be just because the dynamic screen handling stuff was too new to have been included in the engine at that point, but would be "soon".
It is easy to see there may be confusion with a "game loop" scenario here.
It is easy to see there may be confusion with a "game loop" scenario here.
Re: Moving Image within the card from right to left
Oh, sorry, since I did not attend the "Game Academy" I did not know that!
I only saw some scripts posted here with that handler.

I only saw some scripts posted here with that handler.