Send message to stack

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
Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Send message to stack

Post by Akatz » Thu Nov 17, 2011 10:49 am

Continuing from the last post I made, I am currently implementing a life feature into my game. For the whole game of Spot the Difference, you have 3 lives and I currently have this code on the first level :

on mouseUp
if the visible of image "Life 3" = true then
set the visible of image "Life 3" to false
else if the visible of image "Life 2" = true then
set the visible of image "Life 2" to false
else
go to stack "End Menu"
end if
end mouseUp

I want to make it so the lives carry onto the next stacks and if all the lives are gone, it will go onto the last stack which is the end menu. Also, I'm wondering how do I make it so everytime I press the play button, the lives restart back at 3 and not at the previous state. Thanks :)

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Send message to stack

Post by Klaus » Thu Nov 17, 2011 11:24 am

Hi Akatz,

sorry, but I don't have the slightest idea what you are trying to do?!


Best

Klaus

Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Re: Send message to stack

Post by Akatz » Thu Nov 17, 2011 1:07 pm

My bad, was rushing it in school and didn't bother reading it over. So as you know, I'm making a Spot the Difference game and if they click the difference, the next stack will be activated. Each set of picture will have a forfeit button that will go to the next stack and will also take away a life from the 3 given. I'm wondering how to program it so the amount of lives is carried on to the next stack and if all 3 lives are lost, it will go to the end menu. I hope this makes more sense? Thanks

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Send message to stack

Post by Klaus » Thu Nov 17, 2011 1:28 pm

Hi Akatz,

well, I'm still not getting it :D

But it looks like you should use a global variable that can be accessed from EVERY stack you navigate you.


Best

Klaus

cbodell
Posts: 61
Joined: Wed Nov 09, 2011 7:27 pm

Re: Send message to stack

Post by cbodell » Mon Nov 21, 2011 3:38 am

Akatz,

You should use cards instead of stacks, because then you can group your "lives" images together and have them carry over card to card easier. In the properties palette, for a group, you can choose a property labeled "Behave like a Background". So when you switch from card to card, the group of "lives" images carries over card to card in the exact same place. However, if you want to move the group of "lives" images on each card, then you have to add a "preOpenCard" handler and set the location of the group from within that handler. Easy Enough!?

If you want to push a button, like "reset" for example, to reset level or lives, just invoke this script with the reset button:

Code: Select all

on mouseUp
   lock screen
   show img "life 1"
   show img "life 2"
   show img "life 3"
   unlock screen
pass mouseUp
* It shows all three lives images at once

Keep in mind, i am under the assumption you have three images total, for the "lives" feature.

Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Re: Send message to stack

Post by Akatz » Thu Nov 24, 2011 11:40 am

I think I'll change from using stacks to cards now.
Yes I do have all 3 images of the lives grouped as "Lives" so can you please help me more on the carrying on lives from 1 card to another? Thanks

Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Re: Send message to stack

Post by Akatz » Thu Nov 24, 2011 4:24 pm

I've changed all my substacks into cards now. I've got all 3 life images in a group called 'Lives' and I set it to the behave like background but it doesn't carry over to other cards? Also, can you help me with the code that'll deduct a life moving it to the next card? Thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Send message to stack

Post by dunbarx » Thu Nov 24, 2011 5:36 pm

You may have encountered a certain fact about LC. This is different from how Hypercard worked.

If you already have an object, like a group, on one card, changing it to act like a background will not automatically "place" it on other cards that already exist.

If you create a new card, however, that background object WILL appear on that new card.

So the issue, in other words, is whether you start with a background object and make new cards, or already have several cards with an object on one card that you change to "background"

Read up on the "place" command in the dictionary. This allows you to get your objects on all cards. Then when you make new cards, you are set.

On another note, you continually ask for complete code routines for your project. Firstly, you should do this yourself. Secondly, and I think you will appreciate this after you get into it, there is no way for anyone to do this. We will not really know what you want, only you will. And the effort, though fun, exciting and engaging, is large.

But write back with anything; you will always get help. Quite a bit of it.

Good luck.

Craig Newman
Last edited by dunbarx on Sat Nov 26, 2011 6:24 am, edited 1 time in total.

Akatz
Posts: 12
Joined: Mon Oct 31, 2011 1:28 pm

Re: Send message to stack

Post by Akatz » Fri Nov 25, 2011 10:10 am

Sorry when I say I want the code, I mean help with the code as I am not 100% famaliar with Live Code. I'll try creating new cards to see if the lives appear on the new cards, thanks

Post Reply