GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Question about properties in Game and self

When read examples, i always can see such rule:
Change Attribute: set game.Player X to self.Position.x
I don't quite understand the game and self, can someone help to explain?
which actor will be game.Player X if several actors in Scenes?

Comments

  • GS_MasterGS_Master Posts: 159Member
    huh?
  • grimtoothgrimtooth Posts: 69Member
    @Edwin123_chen

    What is happening is that people create a game attribute to transfer store or display a property of an actor. Gamesalad does not allow one actor to look at the properties of another actor directly, but any actor can access game or scene properties so this is done as a workaround.

    Game attributes can be very versatile and powerful tools and make game updates, changes, or reworks to be done very easily because you can make changes to multiple actors by only changing a single line or number.

    A great example of this is that my current project has some "Snap-to-Grid" functionality for many of the actors. If later on I want to change the grid size from 32 pixels to 64 pixels, all i have to do is change the game attribute Grid.Size.X and Grid.Size.Y that I created. IF i had programmed the grid size into each actor and decided to change it later, I would have to edit 30-40 actors!

    Grim
  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member
    Don't get caught up in what people name things. Game level attributes can be named whatever you want. Self means it's an attribute related to the actor itself. So self.position X is the position of the actor in pixels on the scene at the x axis or left to right. Y axis is up and down in pixels. So if I wanted to track a particular actors current X position on the screen I would make a game.level REAL type attribute and using a constrain attribute behavior to tell the actor to report it's X position to the game.level attribute I made. This will allow me to have other actors access that data. Basically all your doing is sending data to a point where other actors can see the data.
This discussion has been closed.