set reference point not working

I am trying to set the reference point of objectt to the center but I think my class is causing problems

I would really appreciate some help  :slight_smile:

[lua]

– Destroyer.lua


local Destroyer = {}

local Destroyer_mt = { __index = Destroyer }    – metatable


– PRIVATE FUNCTIONS


local function getDestroyerYears( realYears )    – local; only visible in this module

    return realYears * 7

end

local function set_referance_point(objectt)

    objectt:setReferencePoint(display.CenterReferencePoint);

end


– PUBLIC FUNCTIONS


function Destroyer.new(x,y)    – constructor

        

    local newDestroyer = 

    {

        Health = 100,

        money = 1000,

        object = display.newImage( “deathstar.png”,x,y )

    }

    set_referance_point(newDestroyer.object)

    return setmetatable( newDestroyer, Destroyer_mt )

end


function Destroyer:print_confirmation()

    print(  “Destroyer Has been created” )

end


return Destroyer
[/lua]

If you set X and Y after setting the reference point it should work.

Thanks that fixed it. Quick Question : Do you always have to set the reference point before the x and y? I so why?

If you set X and Y after setting the reference point it should work.

Thanks that fixed it. Quick Question : Do you always have to set the reference point before the x and y? I so why?