Why in some games i see an expression type: size.width/2 or mouse.position.x/2?

Danix1996Danix1996 Member Posts: 6
edited July 2012 in Working with GS (Mac)
What is the function of divide the size or position?

Best Answer

  • lukey5227lukey5227 Posts: 111
    Accepted Answer
    Everything has uses. If somebody needs to add something between the left side of the screen and the mouse, they'll use this to find the center point. You can also find the left or right side by adding or subtracting from the center point the width/2.

Answers

  • Danix1996Danix1996 Member Posts: 6
    i tried : size.width/2+mouse.position.x and the actor increment the size . Why?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    This is done to reach the end of an actors size. In GS the mouse position is located in the direct center of an actor so you see these type of expressions to count the number of pixels from the center to the left or right of the actor. From center mouse x of an actor 100 pixels wide there are 50 pixels on each side which in a equation would be width /2. The / means divide by. Expressions are math equations, algebra, geometry. To learn more about using expressions you need to understand those types of math. Especially geometry and calculus as those kinds of equations are how you do vectors which is the foundation of moments in a computer not in a straight line. Which is why we have vector to angle, cos, sin and tan these are used to determine angles.
  • Danix1996Danix1996 Member Posts: 6
    Anyone want to teach me the math functions ed expressions like size.width/2 and other objects?

    I pay him 20 $
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    What are you talking about? It just divides the actors current width in half. Theres various uses but one is to find the X-position at a right or left edge of the actor.

    And "self.width/2" is not a function that the expression ''/" is the function and it just means to divide the values

    You really need to be more specific about what you want to do or learn before where going to be able to help you. For Example….
    i tried : size.width/2+mouse.position.x and the actor increment the size . Why?
    What did you try this with. Change Attribute, Interpolate Attribute, Constrain Attribute, Etc…. ?
    What are you trying to accomplish? We cannot read minds so it is imperative that you are as descriptive as possible.
Sign In or Register to comment.