Hi again!
So today I have a problem with the outline of my player.
I created an outline of my player and implemented physics on it. My player is a sprite object, with 3 sequences. The dafault is “walk”, then with a tap event it changes to jump or crouch.
I need the outline to change together with the display object (so to change when the frame changes).
This is my code:
local sheetOptions = {
width = 450,
height = 500,
numFrames = 40
}
local sheet_runningPeste =graphics.newImageSheet( “img/player.png”, sheetOptions)
–struttura dati per definire i frame da riprodurre
local seqs = {
{ name = “walk”,
start = 1,
count = 16,
time = 750,
loopCount = 0,
loopDirection = “forward”
}, {
name = “jump”,
start= 17,
count = 9,
time = 1500,
loopCount = 1,
loopDirection = “forward”
},{
name = “crouch”,
start= 26,
count = 11,
time=1200,
loopCount = 1,
loopDirection = “forward”
}}
–creo oggetto sprite
player = display.newSprite ( sheet_runningPeste, seqs)
player.x = display.contentCenterX-670
–player.y = display.contentHeight-300
player.offset=0
– imposto di default la sequenza walk
player:setSequence(“walk”)
player.isNotWalking = false
player.isJumping=false
player.isCrouching=false
player.isVisible = true
– aggiunta di un corpo fisico dinamico all’oggetto player
– la cui forma e’ esattamente il contorno dell’immagine spritePeste.png
local frameOutline = player.frame
local pesteOutline = graphics.newOutline(5, sheet_runningPeste, 1)
physics.addBody(player,"dynamic",{outline=pesteOutline, bounce=0.0})
player.isFixedRotation = true -- Si impedisca che l'oggetto player ruoti
player.myName = "player"
Here I tried to do it with object.frame saved in local frameOutline and giving tis variable as frameIndex for outline image sheet (https://docs.coronalabs.com/api/library/graphics/newOutline.html)
local frameOutline = player.frame
local pesteOutline = graphics.newOutline(5, sheet_runningPeste, frameOutline)
But it doesn’t work.