hi,
i search to move my character only if his rotation==0 or 180 (the basic of a platform game)
but the problem is that the value :character.rotation is incremental…and i receive the signal “ok” one time
if I could do this
if character.rotation == number that can be divided by 180 then …
but i can’t code this…
local physics = require("physics") physics.start() physics.setScale(15) physics.setGravity(0,22) local borderBottom = display.newRect( 0, 230, 2080, 10 ) physics.addBody( borderBottom, "static", borderBodyElement ) local sheetData = { width=13, height=12, numFrames=7, sheetContentWidth=91, sheetContentHeight=12 } local mySheet = graphics.newImageSheet( "sprite2.png", sheetData ) local sequenceData = { { name = "runFast", frames={ 1,2,2,2,5,7,5,6,5,1,2,4,5,6,2,5,1 }, time=6000 } } local character = display.newSprite(mySheet, sequenceData ) character.y=100 character:setSequence( "runFast" ) character:play() character.rotation=0 physics.addBody( character, { density=1, friction=1, bounce=0.3,shape=pentagonShape } ) local function rebond() rebondx=mathRandom(-100,100) character:applyForce( rebondx, -100, character.x, character.y ) end timer.performWithDelay(1000,rebond,-1) local function testRotationCharacter() print(character.rotation) if character.rotation == 0 then print("ok") end end Runtime:addEventListener("enterFrame", testRotationCharacter)
on the forum i have see this
character.isFixedRotation = true
but that don’t work by me