GameSalad

Undo Button

AkhwaAkhwa Posts: 11Member, PRO

Hello Guys,
I want to create undo button for a Coloring Book App (Select2fill) so i can go 1 step back,but cant figure out how to
i am using a Select color to fill technique for my coloring using game.integer(color.game)

Thanks in advance :)

Comments

  • tatiangtatiang Posts: 11,027Member, Sous Chef, PRO, Senior Sous-Chef
    edited October 16

    How are you doing the "select color to fill technique"? And what is it that you want to undo... just the color selection or the actual fill (pixels changing color)?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • AkhwaAkhwa Posts: 11Member, PRO

    i created a global game integer called game.color
    and i've added a color button with:
    when touch is pressed change attribute game.color=1
    for each color button with a different number each
    and for the sketches each part has a group of rules which is
    when touch is pressed if game color=1(as an example)
    change attribute self color red to 1
    change attribute self color green to 0
    change attribute self color blue to 0
    for all the palette colors iam going to add
    for the undo i want it to go step back each click
    so if i do lets say 5 steps
    1-change color to red
    2-change color to blue in another part of sketch
    3-change color to green
    i want when i press the undo button it goes back to step 3 state,then 2 and so on

    Thanks for your time

  • tatiangtatiang Posts: 11,027Member, Sous Chef, PRO, Senior Sous-Chef

    Okay, then just record each color change in a table with each column representing a color value (red, green, or blue):

    1 1 1
    1 0 0
    1 0 1
    1 1 1
    0 1 1
    etc.

    If you press the undo button, you just change the current color to the values in the row above the last row (tableRowCount(tableName)-1) and then delete the last row as long as there are at least two rows.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • AkhwaAkhwa Posts: 11Member, PRO

    Okay thanks tatiang i'll try this method :)
    appreciate the help

  • AkhwaAkhwa Posts: 11Member, PRO

    @tatiang said:
    Okay, then just record each color change in a table with each column representing a color value (red, green, or blue):

    1 1 1
    1 0 0
    1 0 1
    1 1 1
    0 1 1
    etc.

    If you press the undo button, you just change the current color to the values in the row above the last row (tableRowCount(tableName)-1) and then delete the last row as long as there are at least two rows.

    can you break it down more onto detail as i cant keep up with what you said
    Sorry :blush:

  • tatiangtatiang Posts: 11,027Member, Sous Chef, PRO, Senior Sous-Chef

    For your color values, you might have integer attributes called game.red, game.blue, and game.green. The algorithm would be:

    If [select new color]
         Add row to table
         Change table values to color values (e.g. col 1=1, col2=0, col3=1)
         Save table

    If [undo]
         Change color values to table values from last row (tableRowCount(tableName)
         Delete table row [tableRowCount(tableName)]

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • AkhwaAkhwa Posts: 11Member, PRO

    i have a integer attribute called game.color which identifies the color number and with each color number i add change attribute to the color values
    so simply how my selection button looks
    if touch is pressed change game color to 1 (as an example)
    for my coloring sketch each part carrys rules identifying each game color value
    so as an example for the red
    when touch is pressed if game color is 1
    change attribute
    self color red to 1
    self color green to 0
    self color blue to 0

    so how i can hook up the game color value to tables and how the integer attributes u mentioned should work with this

Sign In or Register to comment.