makotok/Hanappe

Pivot points not working correctly

Closed this issue · 3 comments

setPivToCenter() doesn't do anything whatsoever.
setPiv(x, y) doesn't do anything...

The reason? you add the pivot when you set the position...
The whole idea of a pivot is that you /don't/ add it, because that becomes the center of the object.

I also don't get the restriction of staying inside the screen boundaries, but that's your design choice.

Can't attach a zip, so here's a whole example:

-- main.lua
flower = require "flower"

flower.openWindow("", 400, 400)
flower.openScene("scene")
-- scene.lua
module(..., package.seeall)

local layer = flower.Layer()
local image = flower.Image("cathead.png")

function onCreate(e)
  scene:addChild(layer)

  image:setSize(200, 200)

  image:setPivToCenter()
  image:setPos(200, 200)

  image:setPiv(100, 100)
  image:setPos(200, 200)

  image:setLayer(layer)
end

No problem.
setPos is a function of the order without having to rely on a central point, to move the upper left corner at the origin.
When moving through the center point, please use setLoc.

In addition, Image inherits the DisplayObject.
Method can be used for all of MOAIProp.

image:setPiv(100, 100)
image:setLoc(200, 200)

I was a little mistake.

image:setPiv(100, 100)
image:setLoc(200, 200, 0)

PS:

flower wrapping are not basically.
That is MOAIProp, MOAITextBox, MOAILayer.