I have a move left and right animation however when I modify the xScale of my sprite to look left while running or look right while running it flips to the proper direction but also skews the image.
Movement is fine, its when I make the object look left that is skews my sprite.
Here is my code
----------------------------------------------------------------------------------------- -- Gingerbread Dash -- main.lua -- ----------------------------------------------------------------------------------------- -- includes local physics = require( "physics" ) --physics.setDrawMode( "hybrid" ) physics.start( ) -- dimension setup local width = display.actualContentWidth; local height = display.actualContentHeight; local centerX = width/2; local centerY = height/2; display.setDefault( "isAnchorClamped", false ) local scaleFactor = 1.0 local physicsData = (require "physicsData").physicsData(scaleFactor) ---------Display Objects------------ --BG Wallpaper local bg1 = display.newImageRect( "ui/bg1.png", width, height); bg1.x = 0 bg1.y = 0; bg1.anchorX = 0; bg1.anchorY = 0; local bg2 = display.newImageRect( "ui/bg1.png", width, height); bg2.x = bg1.width+.25; bg2.y = 0; bg2.anchorX = 0; bg2.anchorY = 0; --Bounds local bounds = {}; bounds.anchorY = 0 bounds.anchorX = 0 bounds['left']=display.newRect( 0, centerY, 10, height ) bounds['right']=display.newRect( width, centerY, 10, height ) bounds['bottom']=display.newRect( centerX, height, width, 12 ) bounds['top']=display.newRect( centerX, 0, width, 12 ) physics.addBody( bounds["left"], "static", { density=3.0, friction=0.5, bounce=0.3 } ) --Add bounds physics physics.addBody( bounds["top"], "static", { density=3.0, friction=0.5, bounce=0.3 } ) --Add bounds physics physics.addBody( bounds["right"], "static", { density=3.0, friction=0.5, bounce=0.3 } ) --Add bounds physics physics.addBody( bounds["bottom"], "static", { density=3.0, friction=0.5, bounce=0.3 } ) --Add bounds physics --Platform local platform = {"island1\_winter.png","island2\_winter.png","island3\_winter.png","island4\_winter.png"} local plat1 = display.newImageRect( "ui/"..platform[1], 100, 25 ) plat1.anchorX = .5 plat1.anchorY = .5 plat1.x = centerX-150 plat1.y = height-100 physics.addBody( plat1, "static", {density=3.0, friction=0.5, bounce=0.3 } ) ----------------Methods-------------- --Hero local hSheetData = { width = 166, height = 285, numFrames = 12, sheetContentWidth = 1950, sheetContentHeight = 1385 } local heroAnim = { { name = "run", frames = {3,4,5,6}, time = 500, loopCount = 0 }, { name = "rest", frames = {9,10,12}, time = 1000, loopCount = 0 } } local sheetInfo = require("punkie") local myImageSheet = graphics.newImageSheet( "hero/punkie.png", sheetInfo:getSheet() ) local sprite = display.newSprite( myImageSheet , heroAnim[2] ) sprite:scale( .25, .25 ) sprite:play() sprite.x = plat1.x; sprite.y = plat1.y-44; local pentagonShape = { 0,-26, 17,-10, 12, 34, -19,34, -22,-20 } physics.addBody( sprite, { density=3.0, friction=0.8, bounce=0.3, shape=pentagonShape } ) --Buttons local left = display.newRect( 30, 30, 30, 30 ) --Hero Movement -- BG left local function bgLeft( self, event ) if self.x \< -(width-3) then self.x = width else self.x = self.x - 1 end end --Cloud Movement local function platformLeft(self, event) if self.x \< -100 then local newY = math.random(-20,10); -- Set new cloud y position self.y = newY self.x = width else self.x = self.x - 2.5 end end local function leftSPD(event) if(event.phase == "began" or event.phase == "moved") then sprite:setSequence( heroAnim[1] ) sprite:play() heroMS = 1 else heroMS = 0 end end local function charLeft(self, event) if(heroMS == 1) then sprite.x = sprite.x - 2 end end ----------------Listeners------------- -- BG Listener bg2.enterFrame = bgLeft bg1.enterFrame =bgLeft left:addEventListener ("touch", leftSPD) left.enterFrame = charLeft Runtime:addEventListener("enterFrame", charLeft) Runtime:addEventListener( "enterFrame", bg1 ) Runtime:addEventListener( "enterFrame", bg2 )