Closed flexd closed 11 years ago
You can get the shape center using shape:center(). You can also move the shape with shape:move(dx,dy) and shape:moveTo(x,y).
shape:center() is not returning y at all,
trying to print("Player: ", player:center()) and getting just "Player: 404" where 404 = X.
Works fine at my end:
r = (require 'HardonCollider')():addRectangle(10,10,100,100) print('center:', r:center()) --> center: 60 60
Are you sure you are not discarding values (see section 2.5 of the Lua manual)? I.e. doing something like:
print("Player: " .. player:center()) print("Player: ", player:center(), "stuff")
I'm doing this exactly:
local position = player:center()
print("Position is: ", position)
And getting this out:
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
Position is: 425
There's your problem, you're only retaining one value!
local x, y = player:center()
print("Position is: ", x, y)
Oh, sneaky!
Now I just need to get the camera controls working properly and we are in business! Thanks for the help :)
How is this possible?
I'm moving my camera based on my player object, which is now a Collission:addRectangle() shape, but I can't seem to use player.x/y any more.
How can I get the position of the rectangle/object?
I want to be able to do something like this