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 8668739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:17:23+00:00 2026-06-12T18:17:23+00:00

I am using box2d and attempting to create a chain shape. In order to

  • 0

I am using box2d and attempting to create a chain shape.

In order to create a chain shape or polygon shape I must pass an array of vectors in order to specify the geometry.

I do not see any documentation to help me accomplish this, and the notes about bindings here don’t go into any detail about arrays.

How can I construct an array?

  • 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-06-12T18:17:24+00:00Added an answer on June 12, 2026 at 6:17 pm

    I have solved this problem by using these (as yet undocumented) emscripten features.

    Note that I am accessing the functions and values (like ALLOC_STACK and wrapPointer) out of the Box2D object simply because that is the scope where I have found them to be exposed. They are emscripten-specific values, so for a different project and/or build settings it would be different.

    // an alternative method that may work (shorter, less obvious code) is 
    // allocate([v1x,0,0,0,v1y,0,0,0,v2x,0,0,0,...], 'float', Box2D.ALLOC_STACK);
    // 8 byte per vector * 4 vectors = 32 bytes of memory required 
    var buffer = Box2D.allocate(32, 'float', Box2D.ALLOC_STACK);
    Box2D.setValue(buffer, left, 'float'); // v1x
    Box2D.setValue(buffer+4, bottom, 'float'); // v1y
    Box2D.setValue(buffer+8, right, 'float'); // v2x
    Box2D.setValue(buffer+12, bottom, 'float'); // v2y
    Box2D.setValue(buffer+16, right, 'float'); // v3x
    Box2D.setValue(buffer+20, top, 'float'); // v3y
    Box2D.setValue(buffer+24, left, 'float'); // v4x
    Box2D.setValue(buffer+28, top, 'float'); // v4y
    var ptr_wrapped = Box2D.wrapPointer(buffer, Box2D.b2Vec2);
    shape.CreateLoop(ptr_wrapped, 4);
    body.CreateFixture(shape,0.0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using AndEngine/Box2D to create a game. When the game loads, an array of
i am using box2d to developed iphone game.But i have not a lot of
I'm using Box2D through Libgdx to create a scene. I have a scenario where
I'm using Box2D (the AS3/Flash version, if it matters) and I'm trying to calculate
I am using Box2d for a topdown game. The ground is a series of
Salut, I'm currently working on a pool game in flash, using box2d for physics
I'm using AndEngine/Box2d to develop a game. I have a ball that bounces around
I'm using AndEngine and Box2d to develop a game. I'm applying a force to
I'm using Cocos2D 1.0.1, and it doesn't get the latest Box2d. So, I would
I'm writing an XNA game in C# using the XNA port of Box2d -

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.