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
-
ethanCodes
- Posts: 46
- Joined: Sun Feb 14, 2016 9:08 am
Post
by ethanCodes » Sat Feb 27, 2016 5:07 am
I am making a Tower Defense game for a class and am trying to get the image of the "enemy" to move across the screen. I can't seem to get it to work though. I watched a tutorial online of something similar and thought I had it figured out but it's not doing anything. Here is what I've got so far:
this is attached to the image "Miner" card (the Miner is the enemy)
Code: Select all
on cardOpen
move image "Miner" to the points of graphic "pathEnemy" in 10 seconds without waiting
end cardOpen
and this is attached to the card script:
Code: Select all
on preOpenCard
set the location of image "Miner" to 44.713
end preOpenCard
-
quailcreek
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
Post
by quailcreek » Sat Feb 27, 2016 5:21 am
Hi Ethan,
You are confusing LC. You are telling it to do something in 10 seconds without waiting. You can either say in 10 seconds or you can say without waiting but not both. If you say 10 seconds, it will take 10 seconds for the image to traverse the path. If you say without waiting, LC uses a system moveSpeed value to traverse the path.
Code: Select all
on cardOpen
move image "Miner" to the points of graphic "pathEnemy" in 10 seconds
end cardOpen
Code: Select all
on mouseUp
set the moveSpeed to 50
move image "Miner" to the points of graphic "pathEnemy" without waiting
end mouseUp
Tom
MacBook Pro OS Mojave 10.14
-
ethanCodes
- Posts: 46
- Joined: Sun Feb 14, 2016 9:08 am
Post
by ethanCodes » Sat Feb 27, 2016 6:00 am
So I changed that but I'm getting an error for the code that is supposed to set the location of the Miner image.
-
ethanCodes
- Posts: 46
- Joined: Sun Feb 14, 2016 9:08 am
Post
by ethanCodes » Sat Feb 27, 2016 6:03 am
and even if I comment out that code, it still doesn't move...
-
quailcreek
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
Post
by quailcreek » Sat Feb 27, 2016 6:55 am
It should be 44,713 not 44.713
Tom
MacBook Pro OS Mojave 10.14
-
ethanCodes
- Posts: 46
- Joined: Sun Feb 14, 2016 9:08 am
Post
by ethanCodes » Sat Feb 27, 2016 11:45 pm
ah I see, I didn't catch that period! Thank you! I will see if this works. Also, thank you Alejandro for the links!
-
quailcreek
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
Post
by quailcreek » Sat Feb 27, 2016 11:58 pm
Then there must be something else in you code that's stopping it. See if this helps.
Maybe it's openCard not cardOpen
-
Attachments
-
- Move Test.zip
- (1.28 KiB) Downloaded 250 times
Tom
MacBook Pro OS Mojave 10.14
-
ethanCodes
- Posts: 46
- Joined: Sun Feb 14, 2016 9:08 am
Post
by ethanCodes » Sun Feb 28, 2016 2:25 am
so if I change it to on mouseUp it works, but I need it to start by itself after a certain amount of time. I know how to set the time, but for now I just want it to start immediately. But for whatever reason it won't do anything with the on openCard (and you were right it is on openCard, not on cardOpen).
-
ethanCodes
- Posts: 46
- Joined: Sun Feb 14, 2016 9:08 am
Post
by ethanCodes » Sun Feb 28, 2016 2:33 am
I figured it out! the code to move the miner can only be "on openCard" if it is on the card's script, not the miner's script.
-
quailcreek
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
Post
by quailcreek » Sun Feb 28, 2016 2:55 am
Good for you, Ethan. You were able to figure out the problem. You're on your way to writing some great apps.
Tom
MacBook Pro OS Mojave 10.14