In-Game Actor Change System?
So I'd like to be able to spend an attribute (along the lines of game.Coins) on a character from my "locked characters" scene.
Could someone explain how to have an actor replace another actor if 'purchased' and selected within the "locked characters" scene? Meaning, when a person clicks the icon to purchase and select the new character, it replaces the existing actor with the new one (and remains to be that character even upon reopening the application).
Perhaps someone knows of a demo or tutorial? Any assistance would be greatly appreciated. Thanks.
Could someone explain how to have an actor replace another actor if 'purchased' and selected within the "locked characters" scene? Meaning, when a person clicks the icon to purchase and select the new character, it replaces the existing actor with the new one (and remains to be that character even upon reopening the application).
Perhaps someone knows of a demo or tutorial? Any assistance would be greatly appreciated. Thanks.
Best Answers
-
jckmcgraw Posts: 647
@Evanberger5
Create an integer attribute called game.character and set it to 1.
In the character actor, have a rule that says if game.character = 1, have all rules and stuff that you want character one to do (maybe a change image), or stuff like that.
Then, create another rule that says if game.character = 2, have all the stuff for that character.
Create those rules for however many characters you have.
Now, in your character buying scene create an actor that we will use self.attributes for to say which character to unlock. In your unlocking character actor, create an integer attribute called self.coins. Create another attribute called self.character#.
Rules in the actor:
When touch is pressed and game.coins is > than self.coins, change attribute game.character to self.character#. Timer (just in case) 0.1 sec after that (still in the rule), save attribute game.coins and game.character
The purpose for the self.attributes is so that you don't have to unlock any of the buttons you make.
In your first scene of your app, be sure to load game.coins and game.character.
The version of the store that I created for you, would not unlock a character, but would require you to buy a different character every time you use them. If you would like to make it so that it just unlocks them, it would be a little more complicated but not too much.
Hope this helps,
Jack McGraw -
MotherHoose Posts: 2,456
one way:
gameAttribute … Text type … playerImage …leave blank
gameAttribute … Index type … coins
in your shop:
on each newActorImage:
selfAttribute: myPrice … Index type … and enter the coins needed to purchase this actor
Rule: when (All)
Event: touch is pressed
Attribute: game.coins ≥ self.myPrice
-changeAttribute: game.playerImage To: self.myImage
-changeAttribute: game.coins To: game.coins-self.myPrice
on playerActor:
Rule: when
Attribute: game.playerImage is leave blank
-changeAttribute: self.Image To: original image
-Otherwise: constrainAttribute: self.Image To: game.playerImage
short demo: http://www.mediafire.com/?2vdp21kebdb134d
MH
EDIT: save/load those two gameAttributes to have correct when user reopens game
Answers
Regards,
Jack McGraw