Undo Button

AkhwaAkhwa Member, PRO Posts: 11

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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited October 2017

    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 Member, PRO Posts: 11

    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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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 Member, PRO Posts: 11

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

  • AkhwaAkhwa Member, PRO Posts: 11

    @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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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 Member, PRO Posts: 11

    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.