Somewhat advanced question (I think)
xtiaan
Member Posts: 4
Hello GS Community,
Maybe Im getting a little in over my head here... but there is not a whole lot of documentation yet for GS, so here is the only place I can turn for answers.
Say I have Scene 1... and I jump to scene 2 and have a choice of 10 fruits to choose from. I select two apples, one orange, one banana and one watermelon. Now I want to return to Scene 1 and see the previously selected fruit 'drop' down from the top of the screen and on to the stage, ready to interact with.
How would I set up the rules etc for this scenario. I kind of have it working, but I know Im not doing it correctly, and like I said, I can't find any info for this.
Thanks in advance... I'd really appreciate any help.
Maybe Im getting a little in over my head here... but there is not a whole lot of documentation yet for GS, so here is the only place I can turn for answers.
Say I have Scene 1... and I jump to scene 2 and have a choice of 10 fruits to choose from. I select two apples, one orange, one banana and one watermelon. Now I want to return to Scene 1 and see the previously selected fruit 'drop' down from the top of the screen and on to the stage, ready to interact with.
How would I set up the rules etc for this scenario. I kind of have it working, but I know Im not doing it correctly, and like I said, I can't find any info for this.
Thanks in advance... I'd really appreciate any help.
Comments
integer apples
integer oranges
integer watermellons
integer bananas
integer nextType = -1
---------------------------------------
actor fruit
attribute integer called type
// this sets the image to a file 0.png, 1.png, 2.png, 3.png, or 4.png each of which is a diff fruit.
constrain attribute Image = self.type .. ".png"
// this is for when you drop them
rule when game.nextType != -1
self.type = game.nextType
// this is for when you select them
rule when touch pressed:
when type = 0
game.apples = game.apples + 1
when type = 1
game.oranges = game.oranges + 1
when type = 2
game.watermellons = game.watermellons + 1
when type = 3
game.bananas = game.bananas + 1
----------------------------
scene 2 (the select fruit scene)
4 instances of fruit actor each instance gets modified to have the self.type attribute set to one of 0, 1, 2, 3, or 4.
1 exit button to return to scene 1 (the fruitfall)
-------------------------------
scene 1 (the fruitfall)
gravity = 100
scene controller actor:
timer every 0.1s
change attribute game.nextType = random(0,4)
spawn actor fruit position relative to scene x=random(0, display.width), y=display.height
------------------
Hmm.. I got to go, you still need to check the count of the number of types of fruits selected and then reduce them by one every time the fruit of that type spawns. Do it in the fruit actor.