Hi!
I have a game where I create a displayGroup and set the y value to -96. The x value I don’t set, so I would assume that to be zero.
Now, later on in my game when I set the X value to zero, the displayGroup falls off the stage completely. In fact, getting the X value of the displayGroup gives a superhigh number: 2147483648.
Not only that, but setting the value to a bit less doesn’t work that well either, e.g. setting the number to 20 less doesn’t show any difference in X position on screen. Setting it 300 less gives a differences of 128 pixels on screen, and more of these weird results - I know it’s 128 pixels because it is exactly two of my 64 px tiles.
The only code this Grid sees is the following during creation:
-- create grid holding all tiles
Grid = display.newGroup()
Grid:setReferencePoint(display.TopLeftReferencePoint)
--Grid.x = 0
Grid.y = -384
transition.to(Grid, {time=500, delay=300, y=96, transition=easing.outQuad})
Grid.tileSheet = sprite.newSpriteSheet("Elements.png", 64, 64)
Grid.tileSet = sprite.newSpriteSet(Grid.tileSheet, 1, 64)
-- populate the grid with 30 tiles
for y = 0, 5 do
for x = 0, 4 do
local Tile = sprite.newSprite(Grid.tileSet)
Tile:setReferencePoint(display.TopLeftReferencePoint)
Tile.x = x\*64
Tile.y = y\*64
Tile.currentFrame=Array[x+1+y\*5]
Grid:insert(Tile)
end
end
print(Grid.x)
The print statement in the end outputs the weird value already - so the error is present right away after creation, not because of some weird code afterwards. Printing the Y value is correct.
As you can see I’m not doing anything that explains this weirdness, right? By the way, uncommenting the line that says ‘Grid.x=0’ makes the displayGroup jump off the screen immediately.
So… Apparently creating the displayGroup defaults to a X position of 2147483648. If this deviation was predictable I could compensate for this value, but alas, it is not.
Please fix this or help me out!!!
Thanks,
Thomas [import]uid: 70134 topic_id: 14789 reply_id: 314789[/import]