HI I am new to corona sdk and game dev. at the moment I am doing some learning on sticker knight example.
Wanted to ask how to implement attack physic and collision
Sticker-Knight-Platformer/blob/master/scene/game/lib/hero.lua
I have added an attack animation in the sprite and I am having trouble changing the physics body during the attack animation, the *hand* punch outside of the initially defined physic body size and it doesn’t do anything at the moment , does anyone know a good way to implement collision event while the hand is punching
I have tried moving instance anchorX during the attack animation so that it will bump into the enemy* but it get jumpy and I don’t think it’s a good idea.
working example code that I can reference would be nice
Please advice, Thank you
– Add physics
physics.addBody( instance, “dynamic”, { radius = 54, density = 3, bounce = 0, friction = 1.0 } )
– Load spritesheet
local sheetData = { width = 230, height = 200, numFrames = 20, sheetContentWidth = 920, sheetContentHeight = 1000 }
local sheet = graphics.newImageSheet( “scene/game/img/sample.png”, sheetData )
local sequenceData = {
{ name = “idle”, frames = { 1, 2, 3 }, time = 333, loopCount = 0 },
{ name = “attack”, frames = { 20 } }
}
instance = display.newSprite( parent, sheet, sequenceData )
instance.x,instance.y = x, y
instance:setSequence( “idle” )
instance:play()