something easy I am making to hard?

So lets see if I can articulate this correctly :)

I want an item bar at the bottom of the screen...(think slots)

I will have objects that move down the screen (think falling), that will be clicked(touched). once that occurs they move to a position in the bar (lets say there are 8 positions.) place them from left to right.

I have figured out how to position actors based upon a table value, and how to also change the table boolean value...but here is where I am having a mental lock.

I click the first one, it goes to position 1 (I am thinking I make a bottom bar actor with 8 attributes maybe?)....I click the second one, I want it to be placed in the bar, check position 1 - if occupied, go to position 2, and so on. I figure a boolean method of changing the state for each position?

So am I thinking correctly in that when I click each actor, it has to have a statement that checks each position until it finds one open, then places (presumably from a table value) in the open position.

I am just struggling with the logic for each actor in relation to the bottom bar actor (presumably)

Any help is appreciated...in nudging me along

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You're almost there! There's no need to check any booleans as long as you are filling the positions in order. Use math instead of booleans:

    When Touch is Pressed
    .....Change Attribute self.position.X to game.currentPosition*game.barSlotWidth+game.barLeftX
    .....Change Attribute self.position.Y to game.barY
    .....Change Attribute game.currentPosition to game.currentPosition+1

    To explain a bit, game.currentPosition is an integer/index that represents the current open position. This would be set to 1 when the game begins and then would increase after each position is filled. game.barSlotWidth is just the width of a single "position" in the bar (actually, it's the distance between the centers of the "positions" if you have them spaced apart). And game.barLeftX is just the leftmost edge of the bar (where it starts); you can use a number in place of the attribute, of course.

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

  • biffbaxterbiffbaxter Member Posts: 2
    edited January 2013
    Ahhh so easy...That was to obvious...but nice! Works perfectly, and I can tinker with size, position, etc :) - Reminds me of my old days of programming on my Atari 800...but better documented and easier ..yeah I'm old...ha

    Looks like Im going pro this weekend :)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    We old people have to stick together. ;)

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

Sign In or Register to comment.