Moving dynamic Actors together?

MagicShapMagicShap Member Posts: 1
edited January 2014 in Working with GS (Mac)
I am writing a TD game, and I need to constrain each radius to it's corresponding tower. I'd like to avoid global attributes, since I'd like players to be able to create as many towers as they can afford in long levels. How do I constrain a dynamically created tower's radius object to the tower object's position?

I am using a table to hold the tower's attributes ( damage, image, radius size, etc..) and thought "let's constrain a table cell to the tower position" but that is apparently impossible. Any pointers?

Best Answer

Answers

  • 3itg3itg Member, PRO Posts: 382
    edited January 2014
    If I understand correctly, you could diligently update 2 columns in the table (1 for X, 1 for Y) each time you need this info, or regularly with a timer.
    Alternatively, you could use:
    when
    ANY
    self.position.X does not equal tablecellvalue(yerTable, yerRow, yerColumnFerX)
    self.position.Y does not equal tablecellvalue(yerTable, yerRow, yerColumnFerY)

    Change TABLE VALUE behavior:
    Table =yerTable
    Row = yerRow
    Col = yerColumnFerX to Value = self.position.X
    Col = yerColumnFerY to Value = self.position.Y

    if you have alot of stuff going on, you could also add a boolean as a game attribute, and flip this to true when the X&Y attributes don't match the table.

    Then make another actor watch this boolean, if its true, immediately flip it to false, and update all the info in the table and any related actors. It can get pretty complicated, but dont be afraid to add the game attributes you need.
    If they are avoidable... ya know, avoid em, but sometimes they just arent...
  • MagicShapMagicShap Member Posts: 1
    Thanks, I'll take a look at your demo. You two did indeed understand my issue. Of course, now I've got to have the radius that has been collided with trigger the associated tower to fire... oh how I wish actors could communicate better with each other or have pointers, or a parent child relation. Seems like a big gap between GS and other languages.

    I'm planning on having a 'tower_index" and "enemy_index" so the radius can tell the tower to shoot the right one.

    If there's a better way...
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I wish it too, but I think you'll find that my demo functions in the way you were planning so that actors can associate with each other.

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

Sign In or Register to comment.