playMaker

Author Topic: All my tiles draw in the center of the screen  (Read 1948 times)

Ljacobs

  • Playmaker Newbie
  • *
  • Posts: 10
All my tiles draw in the center of the screen
« on: August 06, 2013, 06:19:48 AM »
Hello all,

Lately I've been working on a roguelike. I'm on 3.5.7 so I can't use the awesome free dungeon generator. Money is tight so I'm hesitant to buy map and nav.

So I've been trying to barrel through it myself.

But currently all of my tiles are drawing one atop the other in the center of the screen.

I'm using arraymaker to keep a list of tiles. Each tile has two variables, gridX and gridY.

I have a tile prefab, and a tile in the scene.

As I create tiles, I add them to the list.

I use a nest for loop to get my x and y coordinates. example

i<320 (that's an 80 x 40 playing area.)
     y<80
          x<40

create tile
set tile gridx to x, repeat for y.

This gets me a list of 320 tiles, each with a pair of X,Y coords.

This next part might be redundant, but I've been working on this all night and it's 6:30 AM now.

I then run back through the array, with the same loop and for each item in the array, I use Set Position to set their X to gridx and Y to gridy.
each time I do so, I offset the tile by 13(the amount of space that makes my tiles line up nicely) multiplied by the current value of f (which I used instead of i in the second for loop.

My thinking is that this should create a tidy 80x40 grid with all my tiles neatly spaced as desired.

Instead I get a pile of tile(clones) stack in the middle of the screen.

My next step is to create them all in the center and then iTween them with MoveTo to their gridx, gridy, offset at the fastest possible speed and maybe hid that behind a story panel or something.

I know other people have done this before and much better, but I don't have the cash :) and it seems like this simple solution really should work right?

Thanks,
-Luke

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: All my tiles draw in the center of the screen
« Reply #1 on: August 06, 2013, 07:40:00 AM »
Hi,

 output debug logs to see what are your x and y values you actually inject to set the position, you'll likely find they are 0. Or else, you don't inject the values at all ( or to the wrong gameobject).

You could use the "turtle" way:

have a gameobject that is the tile generator, and move that gameobjec to the tile you want to spawn, and as you spawn, you simply set the position of that new tile to the position of the turtle. and you progress like through the grid.


bye,

 Jean