What's the equivalent of origin() in the latest kaboom?

55 Views Asked by At

I think I'm following an outdated tutorial where using the origin() function to modify the anchor position of an object. But it seems like the function has been removed in the latest version.

const player = add([
  rect(24, 24),
  pos(12, 12),
  color(0, 0, 1),
  area(),
  body(),
  origin("center"), //<--- undefined
]);

So How do I do it now in the latest kaboom version ?

1

There are 1 best solutions below

0
dytra On

It's me from the future, I found it from documentation that we can use anchor() to do the same thing like the origin() function does.

Eg: anchor("center")

add([
    text("Hello Kaboom", {
        align:"center",
    }),
    pos(k.width() * 0.5, k.height() * 0.5),
    anchor("center")

]);