In-Game Actor Change System?

ShineHouseGamesShineHouseGames Member, PRO Posts: 100
edited April 2012 in Working with GS (Mac)
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.

Best Answers

  • jckmcgrawjckmcgraw Posts: 647
    Accepted Answer
    @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
  • MotherHooseMotherHoose Posts: 2,456
    edited April 2012 Accepted Answer
    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

    image MH

    EDIT: save/load those two gameAttributes to have correct when user reopens game

Answers

  • ShineHouseGamesShineHouseGames Member, PRO Posts: 100
    Thank you so much for your help. I really appreciate it. :D
  • ShineHouseGamesShineHouseGames Member, PRO Posts: 100
    @Evanberger5

    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.
    Well, this ^^ is essentially exactly what I'm trying to accomplish (though your post did give much insight into the process). You can email me at evanberger5@aol.com if you'd prefer that over using the forums. :)

  • jckmcgrawjckmcgraw Member Posts: 647
    Sorry I've been busy today especially with 8th grade CST testing this week. I'll figure out another solution within a couple of days when I have time and get back to you.

    Regards,
    Jack McGraw
Sign In or Register to comment.