Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Please help me add physics to a sprite animation
Started by KrisAsante May 11 2018 10:41 AM

2 replies to this topic
help
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

KrisAsante

[GLOBAL: userInfoPane.html]
KrisAsante
  • Observer

  • 1 posts
  • Corona SDK

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



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,404 posts
  • Corona SDK

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
  • You used a default body for the knight.  That won't fit the graphic.

 

  • You tried to listen for a bunch of listeners that were not defined.

 

 

PS - Please use standard sizes/fonts for the main body of your posts.  It is more legible for us if you do.



[TOPIC: post.html]
#3

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 136 posts
  • Corona SDK

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.


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: help