Grid Size Not matching up to background

I've been able to figure out how to make it a swipe to move one box in the grid. Now I'm having the trouble of aligning the grid to the background. Any thoughts on how to do this?


I constrained the character to
self.position.x to: (self.COL)*(game.squaresize)+(game.paddingside)*(game.squaresize)
self.position.y to: (self.ROW)*(game.squaresize)+(game.paddingtopbot)*(game.squaresize)

I followed this from the linked guide. I changed the side padding to be a different attribute from the top/bot padding thinking it would help, but I'm not able to get the character movements to match the background grid. Any help would be great!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I followed this from the linked guide.
    Which guide are you referring to?

    My guess is that your actors are off by a factor of game.squaresize divided by 2. Is that accurate? Can you post a screenshot of what your scene looks like when previewed?

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

  • NY415NY415 Member Posts: 25
    Hey thanks for responding. Here are some screenshots. You can see it starts with the character in a grid square. Then if you move horizontally it stays within each grid square. However, if you move vertically no matter what I do I can't get it to stay in the grid

    http://imgur.com/a/vQ8BM
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I see what you mean but it's hard to know how to help you without seeing the attribute values. What is the value of game.squaresize? How about game.paddingtopbot? What are the actual dimensions of your background image squares and gaps (aka padding)? And what y position does the actor start at?

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

  • NY415NY415 Member Posts: 25
    I believe x and y are starting at 0. Currently I have game square size at 50. Paddingtopbot at 0.1. No matter what I set the paddingtopbot to, it won't stay within the grid. I always goes too far above.

    I'm not entirely sure what the actual dimensions of the background grid is. What is the best way to measure?

    Sorry I'm very new to this
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    That's okay. Are you able to send me a link to download the project file? You can .zip it and upload it to a file-sharing site such as Dropbox or Mediafire and then send me a private message with the link, or post it here if you don't mind making it public.

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

  • NY415NY415 Member Posts: 25
    Ok, so the square size looks to be W48H45 and the grid size is W298H263
  • NY415NY415 Member Posts: 25
    I will PM you give me a sec
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Your character actor is moving up or down 60 pixels at a time. If you put a Display Text behavior with self.Row and self.position.Y, you'll see something like 1|180 or 2|240. This tells me that your rules and constrains are working properly.

    The problem is with the position of your background image.

    If you look at the screenshot below, I added a red line at y=240 and moved the character actor to row 2 (y=240). Your grid squares need to be aligned so that the y position (center of the square) is at y=240. They are currently aligned at about y=228 (see the yellow square).

    image

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

  • NY415NY415 Member Posts: 25
    Awesome, thank you tatiang, my question here would be if there is a way to correct this without changing the position of the grid in the background? Visibly the grid is fitting where the sides are symmetrical and there's enough room for the highscore at the top.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Sure, you can change the constrain formula to add an offset value. Assuming the values are off by about 12 (as in my screenshot above), try this:

    Constrain attribute self.position.y to: (self.ROW)*(game.squaresize)+(game.paddingtopbot)*(game.squaresize)-12

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

  • NY415NY415 Member Posts: 25
    thanks tatiang for all your help I just sent you another message
Sign In or Register to comment.