please help me I’m trying everything I can to fix my code. I just want to add physics to a character (which is named “knight”) and I do not know what I am doing wrong. I’d really appreciate if anyone contributed to my code or tell me what I am doing wrong so that I can fix it. I would like to make the character move in all directions and make it jump with the jump button.
Here is the code: https://github.com/KrisAsante/PhysicsAnimationFail
Hi. I helped, but I think you could have solved this on your own.
https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/05/newbHelp.zip
(Don’t take name of file personally, I had to name it something and I couldn’t think of anything clever.)
Contains original and modified code. Compare with diff program to see changes.
There were a number of simple errors. The console showed the line and a simple lookup here: https://docs.coronalabs.com/api/ would have gotten you rolling.
The big issues I saw:
[list]
-
Do not use . or … in Corona paths: " ./ assets/sprites/land.png"
-
You tried to do this:
local knight = graphics.newImageSheet( “assets/spritesheet/knightIdle.png”, sheetOptionsIdle ) knight.x = display.contentCenterX - 200 knight.y = display.contentCenterY
You should have done this:
local knight = display.newSprite( sheetIdleKnight, sequence\_data ) knight.x = display.contentCenterX - 200 knight.y = display.contentCenterY
PS - Please use standard sizes/fonts for the main body of your posts. It is more legible for us if you do.
Remember when you apply phisics to a display object its like draw geometry figure lines in the display object border, I think it’s the same rule for sprites the only difference it’s you apply phisics to a display object that looks like a .gif instead of an object without multiple frames.
Hi. I helped, but I think you could have solved this on your own.
https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/05/newbHelp.zip
(Don’t take name of file personally, I had to name it something and I couldn’t think of anything clever.)
Contains original and modified code. Compare with diff program to see changes.
There were a number of simple errors. The console showed the line and a simple lookup here: https://docs.coronalabs.com/api/ would have gotten you rolling.
The big issues I saw:
[list]
-
Do not use . or … in Corona paths: " ./ assets/sprites/land.png"
-
You tried to do this:
local knight = graphics.newImageSheet( “assets/spritesheet/knightIdle.png”, sheetOptionsIdle ) knight.x = display.contentCenterX - 200 knight.y = display.contentCenterY
You should have done this:
local knight = display.newSprite( sheetIdleKnight, sequence\_data ) knight.x = display.contentCenterX - 200 knight.y = display.contentCenterY
PS - Please use standard sizes/fonts for the main body of your posts. It is more legible for us if you do.
Remember when you apply phisics to a display object its like draw geometry figure lines in the display object border, I think it’s the same rule for sprites the only difference it’s you apply phisics to a display object that looks like a .gif instead of an object without multiple frames.