No physics for sprites?

local spriteObj = sprite.newSprite(spriteSet1)
physics.addBody(spriteObj, physicsProps)

Result:

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000000000005c
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 …nscamobile.Corona_Simulator 0x000738d4 b2Vec2::Normalize() + 3206
1 …nscamobile.Corona_Simulator 0x00020543 0x1000 + 128323
… etc …

I couldn’t find any physics sample code that uses the game API sprite library, so maybe this isn’t working yet. I’d assume the sprite would appear as a DisplayObject. [import]uid: 3953 topic_id: 1595 reply_id: 301595[/import]

Here’s a good example of physics:
http://blog.anscamobile.com/2010/06/new-video-physics-in-five-lines/

You can see the sample code via the video. I found this link to be helpful as well:
https://developer.anscamobile.com/content/game-edition-box2d-physics-engine

[import]uid: 8045 topic_id: 1595 reply_id: 4606[/import]

Thanks for your answer but you’ve got the wrong question.

I’m familiar with incorporating physics engines into realtime graphics apps.

I want to use Sprites (in the context of the native sprite library: require(“sprite”) and created with: sprite.newSprite(spriteSet)) as rigid bodies, but all the Corona samples, including the one you point to, use DisplayObjects (as in: addBody(DisplayObject)).

When I try to do the same with a Sprite instance, the simulator crashes.

I assumed that the Sprite object would behave similarly to a DisplayObject in terms of attaching rigid bodies etc. [import]uid: 3953 topic_id: 1595 reply_id: 4611[/import]

Have you tried using movieclips?

You can apply physics to it and be able to control what what frame in the moiveclip will play. [import]uid: 8045 topic_id: 1595 reply_id: 4620[/import]

Yes, MovieClips work fine because they’re just DisplayObjects wrapped in Lua code.

The question was about using Game SDK Sprites with physics.

I already have my own C++ framework that handles indexed sprite sequences using texture atlases with attachable 2D rigid bodies (using the Chipmunk lib). I was hoping in switching to Corona I could focus on game logic rather than low level coding. DisplayObjects - and by extension MovieClips - are not a suitable alternative to sprite sheets for games. [import]uid: 3953 topic_id: 1595 reply_id: 4659[/import]

Opened case #597. This is now working in my local build, so it’ll be good in the next drop. [import]uid: 54 topic_id: 1595 reply_id: 4663[/import]

Didn’t make the latest alpha3 drop. Still crashes. [import]uid: 3953 topic_id: 1595 reply_id: 4941[/import]

I’ve tested this, and it seems to work fine for all three physics body types. Here’s working code (using some of the assets from “JungleScene”):

local physics = require( "physics" )  
physics.start()  
  
require "sprite"  
display.setStatusBar( display.HiddenStatusBar )  
  
local baseline = 280  
  
-- A sprite sheet with a green dude  
local sheet2 = sprite.newSpriteSheet( "greenman.png", 128, 128 )  
  
local spriteSet2 = sprite.newSpriteSet(sheet2, 1, 15)  
sprite.add( spriteSet2, "man", 1, 15, 200, 0 ) -- play 15 frames every 200 ms  
  
local instance2 = sprite.newSprite( spriteSet2 )  
instance2.x = 3 \* display.contentWidth / 4 + 30  
instance2.y = baseline - 55  
  
instance2:prepare("man")  
instance2:play()  
  
physics.addBody( instance2, "kinematic", { density = 1.0, friction = 0.5, bounce = 0.2 } )  

Not sure what’s different here from your example (?) And you are correct that a sprite instance is a display object and should behave similarly in this context. [import]uid: 3007 topic_id: 1595 reply_id: 4966[/import]

Thanks for the response. You’re right of course. I omitted physics.start() before addBody(), causing the simulator to blow up. [import]uid: 3953 topic_id: 1595 reply_id: 4985[/import]