When I run the code for game I am creating for my Advanced Higher i can't get the enemy ship to appear on screen and i don't know what is causing this to happen, or rather not happen.
on createalien
create invisible image "canvas.png"
set the loc of image "canvas.png" to (random(500),0)
//Undecied on size yet, Decide on size
set the width of "canvas.png" to 128
set the height of "canvas.png" to 32
movealien
end createalien
on movealien
if the visible of "canvas.png" is false then set the visible of image "canvas.png" to true
set the top of image "canvas.png" to (the bottom of image"canvas.png" + 2)
if the top of image "canvas.png" >= 582 then
delete image"canvas.png"
put (lives - 1) into lives
else
if checkalien() is true then
delete image "canvas.png"
-- hide group "enemy" with visual effect dissolve very fast
set the loc image "shooter" to (327,289)
send startalien to me in random(1000) milliseconds
exit movealien
end if
end if
if there is an image "canvas.png" then send movealien to me in 4 milliseconds
end movealien
This is the section of code I am trying to get to work and spawn in enemies.
"canvas.png" is only the name of the new image control. You may as well call it "strawberry" or "pkghalrx_", it doesn't matter. Before or after you create the image, you have to set the filename or the text of the image. If you have an image "canvas.png" in your stack already, you might do this:
set the itemDel to slash
put item 1 to -2 of the effective filename of this stack & "/canvas.png" into myPath
set the path of the templateImage to myPath
create img
put it into myImg
Variations on these scripts are also possible.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Thanks for code snippets, but when I try to implement them still nothing happens, I have several instances of the image called "canvas.png" on other cards in the stack but even with the snippets in place I can't seem to get anything to happen regarding the spawning "enemies".
Is there any way for me to send you a copy of the stack so that you can look over the content to try and find out what is going wrong?
I never download stacks from the forum because it takes me too much time, which I should reserve for my clients.
Do you have another handler that calls the createalien handler?
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
This is a shot in the dark (I did not analyze your code in detail) but shouldn't the line here:
on movealien if the visible of "canvas.png" is false then set the visible of image "canvas.png" to true
set the top of image "canvas.png" to (the bottom of image"canvas.png" + 2)
...
be:
on movealien if the visible of image "canvas.png" is false then set the visible of image "canvas.png" to true
set the top of image "canvas.png" to (the bottom of image"canvas.png" + 2)
You're right, newbiw, but Samm also says that just nothing happens. It looks like his handlers don't run and he doesn't even see the errors he should be seeing.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode