Noobian question about "position" (SOLVED)

I want:
if myobject.position.x == 100 {
myobject.position.x = - 1
else if myobject.position.x == 0
myobject.position.x = +1
}
like i loop :slight_smile:

How i can do that in Defold.

You probably want other conditions like pos.x < 100 but:

function update(self, dt)
  local pos = go.get_position()
  if pos.x == 100 then
    pos.x = pos.x - 1
  elseif pos.x == 0 then
    pos.x = pos.x + 1
  end
  go.set_position(pos)
end
5 Likes

@SaadiSayβ€”also, if you want to see some code examples of how to do basic things in Defold, check out the Defold Examples section.

4 Likes

ok, thanks)