Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4170630
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:21:40+00:00 2026-05-21T00:21:40+00:00

Can you help. Want to draw a polygon (beams at different angles) and apply

  • 0

Can you help. Want to draw a polygon (beams at different angles) and apply box 2d body to it. Can you please let me know how to create a CCSprite with a polygon shape
Any examples would help
Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T00:21:41+00:00Added an answer on May 21, 2026 at 12:21 am
    1. Create Polygon body.

      -(void) createDynamicPoly {  
          b2BodyDef bodyDefPoly;    
          bodyDefPoly.type = b2_dynamicBody;
          bodyDefPoly.position.Set(3.0f, 10.0f);
          b2Body *polyBody = world->CreateBody(&bodyDefPoly);
          int count = 8;
          b2Vec2 vertices[8];
          vertices[0].Set(0.0f / PTM_RATIO,0.0f / PTM_RATIO);
          vertices[1].Set(48.0f/PTM_RATIO,0.0f/PTM_RATIO);
          vertices[2].Set(48.0f/PTM_RATIO,30.0f/PTM_RATIO);
          vertices[3].Set(42.0f/PTM_RATIO,30.0f/PTM_RATIO);
          vertices[4].Set(30.0f/PTM_RATIO,18.0f/PTM_RATIO);
          vertices[5].Set(18.0f/PTM_RATIO,12.0f/PTM_RATIO);
          vertices[6].Set(6.0f/PTM_RATIO,18.0f/PTM_RATIO);
          vertices[7].Set(0.0f/PTM_RATIO,30.0f/PTM_RATIO);
          b2PolygonShape polygon;
          polygon.Set(vertices, count);
          b2FixtureDef fixtureDefPoly;
          fixtureDefPoly.shape = &polygon;
          fixtureDefPoly.density = 1.0f;
          fixtureDefPoly.friction = 0.3f;
          polyBody->CreateFixture(&fixtureDefPoly);    
      }
      
    2. Create your sprite

    3. Attach your sprite to the Polygon body via Fixture and UserData

      fixtureDefPoly.SetUserData() = spriteObject;  
      b2Fixture *fixture;  
      fixture = circleBody->CreateFixture(&fixtureDefPoly);  
      fixture->SetUserData(@"spriteObject");  
      
    4. Then Iterate the sprite to the body in your update method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyonen help with Teradata? I want to create a query that is a
Can anyone help me out please? I'm confused. I want to set up my
I want to know that how can I add help support to my winform
I want to draw custom button on Navigation bar. Can anybody help me.
Can someone help me on this. I'm made an image uploader and i want
I want fetch last record using hibernate criteria Can u help me?
I want to deallocate my variable? can u help me?
Hi i want to load png images and jpeg images. can anyone help me?
I want to work on the Rijndael algorithm using C#. Can anybody help me
I want to put a background image in mt QWidget, can anyone help me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.