Problem with obj:scale( x, y ).... (!CONFUSED!)

 I’m having trouble with my player flipping direction when I walk right or left. I get confused on the negative value when it has flipped or not, can anyone show a good way of handle this?

  local dt = getDeltaTime()   local update = {}   local function buttonHandler(event)      local target = event.target.id      local phase = event.phase          local move = 0          if phase == "began" then                            if target == "left" then                            player:setSequence("run")              move = - (1\*dt)              player:scale( -1, 1 )                       elseif target == "right" then                          player:setSequence("run")              move = (1\*dt)             player:scale( 1, 1 )         end                  function update()              player:translate(move, 0)          end            Runtime:addEventListener("enterFrame", update)          player:play()          elseif phase == "ended" or phase == "cancelled" then         Runtime:removeEventListener("enterFrame", update)     end     return true end

I’m not sure what you’re trying to do…
Are you wanting to flip your image horizontally?
I f you want to flip horizontally then just put -1 for the x and leave a 1 for the y - object:scale(-1, 1)
… vice verse if you want to flip an object vertically.

-Saer

Edit: http://docs.coronalabs.com/api/type/DisplayObject/xScale.html

Yes I want to flip the image, my problem is knowing if it has flipped or not.

Then just check xScale and yScale parameter

Rather than using the scale function object:scale(-1, 1), I would just change the xScale value manually - this way you get to set an absolute value and not a value relative to the current value.

E.g

--flipped object.xScale = -1 --not flipped object.xScale = 1 

Then if you want to know if an object is flipped, just check the value as piotrz55 said:

if object.xScale == -1 then print("object is flipped") else print("object is not flipped") end

Thanks Alan, I realized if I used xScale then there is no need to check if it has flipped or not.

While I solved one problem I got another…

When I added a jumpButton I had to activate multitouch in order to jump and move, by doing that my Runtime update function “jammed” so the player keep moving and doesnt stop even if touch has ended. What am I doing wrong there?

I’m not sure what you’re trying to do…
Are you wanting to flip your image horizontally?
I f you want to flip horizontally then just put -1 for the x and leave a 1 for the y - object:scale(-1, 1)
… vice verse if you want to flip an object vertically.

-Saer

Edit: http://docs.coronalabs.com/api/type/DisplayObject/xScale.html

Yes I want to flip the image, my problem is knowing if it has flipped or not.

Then just check xScale and yScale parameter

Rather than using the scale function object:scale(-1, 1), I would just change the xScale value manually - this way you get to set an absolute value and not a value relative to the current value.

E.g

--flipped object.xScale = -1 --not flipped object.xScale = 1 

Then if you want to know if an object is flipped, just check the value as piotrz55 said:

if object.xScale == -1 then print("object is flipped") else print("object is not flipped") end

Thanks Alan, I realized if I used xScale then there is no need to check if it has flipped or not.

While I solved one problem I got another…

When I added a jumpButton I had to activate multitouch in order to jump and move, by doing that my Runtime update function “jammed” so the player keep moving and doesnt stop even if touch has ended. What am I doing wrong there?