Swapping Positions of 2 Actors (FIXED)

KevinCrossKevinCross London, UKMember Posts: 1,894
edited August 2013 in Working with GS (Mac)
For my next game I want to be able to place 1 card from a handful of cards into each of the 7 available boxes.

I've achieved this, and the demo project can be found here free for you to use if you find it useful: http://www.kevincross.co.uk/?attachment_id=62

However what I'd like it to do (and I can't get my head around this bit) is to swap cards if there's a card already in the box. At the moment you have to double click on the card to remove it which frees the spot to place in another card, but it would be good to not have to double click, or at least for that not to be the only way to remove/swap a card.

The reason why I'm struggling to find a way to do this is because I don't really know what actor is in the box. I know what colour they are based on an attribute assigned to each card but because cloned actors don't have unique id's I've got no way of really of accessing that card and moving it out of the box, back into it's original place and put in the new card in the box. If I did I'd store the unique ID in a table and not the colour.

Does that make sense? Has anyone swapped actors in a similar way? Or accessed an actor that's sitting in a particular x and y position.

The description on the page with the GameSalad project should help explain what each actor is, because currently it's only coloured squares.

Also it would be good to receive feedback on how intuitive it is at the moment (without tutorials in game to show you how to place and remove cards)

Here's a screenie

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Maybe something like this?

    When (all)
    --overlaps or collides with actor of type card
    --self.dragging is false
    -- --Interpolate self.Position.X To: self.OriginalX
    -- --Interpolate self.Position.Y To: self.OriginalY

    When(all)
    --overlaps or collides with actor of type box
    --self.dragging is true
    -- --Interpolate self.Position.X To: game.SelectedBoxX
    -- --Interpolate self.Position.Y To: game.SelectedBoxY
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Thank you @RThurman, that works perfectly! :)

    And good shout with the interpolate instead of change attribute! I haven't switched all of the change attributes over yet but I can see how interpolate would look better because at the moment the movements are instant.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Great! Glad its gonna work for you.
Sign In or Register to comment.