Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the sprite is dynamic / non-static, just do like so:</p> <pre><code> cpBodySetAngVel(ObjSmSprite.shape-&gt;body,0.25); </code></pre> <p>For a static body, you can do something like this:</p> <pre><code>[ObjSmStaticSprite.shape runAction:[CCRepeatForever actionWithAction: [CCSequence actions: [CCRotateTo actionWithDuration:2 angle:180], [CCRotateTo actionWithDuration:2 angle:360], nil] ]]; smgr.rehashStaticEveryStep = YES; //Setting this would make the smgr recalculate all static shapes positions every step </code></pre> <p>To Summarize, here is a spinning static sprite, following be spinning dynamic sprite.</p> <pre><code> // Add Backboard cpShape *shapeRect = [smgr addRectAt:cpvWinCenter mass:STATIC_MASS width:200 height:10 rotation:0.0f ];// We're upgrading this cpCCSprite * cccrsRect = [cpCCSprite spriteWithShape:shapeRect file:@"rect_200x10.png"]; [self addChild:cccrsRect]; // Make static object update moves in chipmunk // Since Backboard is static, and since we're going to move it, it needs to know about spacemanager so its position gets updated inside chipmunk. // Setting this would make the smgr recalculate all static shapes positions every step // cccrsRect.integrationDt = smgr.constantDt; // cccrsRect.spaceManager = smgr; // Alternative method: smgr.rehashStaticEveryStep = YES; smgr.rehashStaticEveryStep = YES; // Spin the backboard [cccrsRect runAction:[CCRepeatForever actionWithAction: [CCSequence actions: [CCRotateTo actionWithDuration:2 angle:180], [CCRotateTo actionWithDuration:2 angle:360], nil] ]]; // Add the hoop cpShape *shapeHoop = [smgr addCircleAt:ccp(winSize.width/2.0f,winSize.height/2.0f - 55.0f) mass:1.0 radius: 50 ]; cpCCSprite * cccrsHoop = [cpCCSprite spriteWithShape:shapeHoop file:@"hoop_100x100.png"]; [self addChild:cccrsHoop]; cpBodySetAngVel(cccrsHoop.shape-&gt;body,0.25); </code></pre> <p>Disclaimer: I'm trying to answer my own question, and this answer might be missing important subtleties - it just represents what I know, so far.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload