A have a question.
I have two objects:
1) Image
2) Sprite
Both have the same size.
Why when I use applyforce , the sprite move less than the Image? ( I’m talking only about Y, the X value is zero in applyforce function).
Follow the CODE:
local function touch( event )
if ( event.phase == “began” ) then
personagemSprite:applyForce( 0, -9, personagemSprite.x, personagemSprite.y)
image:applyForce( 0, -9, image.x, image.y)
end
end
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5
function scene:create( event )
local sceneGroup = self.view
local background = display.newRect( 0, 0, screenW, screenH )
background.anchorX = 0
background.anchorY = 0
background:setFillColor( .5 )
local grass = display.newImageRect( “grass.png”, screenW, 82 )
grass.anchorX = 0
grass.anchorY = 1
grass.x, grass.y = 0, display.contentHeight
physics.addBody( grass, “static”, { friction=0, bounce = 0 } )
image = display.newImage(“spriteNatanMorrendo.png”)
image:scale( display.contentWidth*0.1 / 55, display.contentWidth*0.1 / 61)
image.x = display.contentWidth*0.5
image.y = grass.y - grass.height/2 - image.height/2
physics.addBody( image, “dynamic”, { friction=0, bounce = 0 } )
local spriteOptionsParado = { width = 55, height = 61, numFrames = 7 }
local spriteParado = graphics.newImageSheet( “spriteNatanCorrendo.png”, spriteOptionsParado )
local spriteSequence = {
{ name=“parado”, sheet = spriteParado, time = 500, start = 1, count = 7, loopCount= 0 }
}
personagemSprite = display.newSprite( spriteParado, spriteSequence )
personagemSprite:scale( display.contentWidth*0.1 / 55, display.contentWidth*0.1 / 61)
personagemSprite.x = display.contentWidth*0.3
personagemSprite.y = grass.y - grass.height/2 - image.height/2
physics.addBody( personagemSprite, “dynamic”, { friction=0, bounce = 0 } )
sceneGroup:insert( background )
sceneGroup:insert( grass)
Runtime:addEventListener(“touch”, touch)
end
