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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:39:10+00:00 2026-05-28T07:39:10+00:00

Working with the Box2djs plugin here: http://www.crackin.com/dev/mms/physics/ … and all I’m trying to do

  • 0

Working with the Box2djs plugin here:
http://www.crackin.com/dev/mms/physics/

… and all I’m trying to do is fill the ball objects with an image texture. I was hoping it was as simple as setting a css value, but I don’t seem to be doing it right as none of the standard background related css rules change the balls. Using a math.random I could create 5 distinct class names to apply to each ball to create the different textured objects.

Here’s an example of what it looks like now, compared to something I could make them look like using images:
M&M Mock Image

This is the specific build of the physics engine I’m using this …
github.com/hrj/box2d-js … which is using jQuery instead of Prototype.

  • 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-28T07:39:11+00:00Added an answer on May 28, 2026 at 7:39 am

    I’ve been playing with Box2DJS a lot and think I’ve found everything I need to implement it for almost anything (e.g. collision detection hooks, etc). Here is a snippet of code that I wrote to integrate a box or circle image in place of a box or circle object:

    if ( myBallImage )
        {
        for ( aBody = world.m_bodyList; aBody != null; aBody = aBody.m_next )
            {
            var jellyObject = aBody.GetUserData();
            if ( typeof(jellyObject) != "object" || jellyObject == null )
                continue;
    
            var position = aBody.GetCenterPosition();
            var angle = aBody.GetRotation();
            var mass = aBody.GetMass();
            var halfheight = 0;
            var halfwidth = 0;
    
            for ( aShape = aBody.GetShapeList(); aShape != null; aShape = aShape.m_next )
                {
                halfheight = aShape.GetHalfHeight();
                halfwidth = aShape.GetHalfWidth();
                }
    
            ctx.save();
            ctx.translate( position.x, position.y );
            ctx.rotate( angle );
            ctx.translate( -halfwidth, -halfheight );   // halfwidth, halfheight
    
            if ( jellyObject.shape == "MYBALL" )
                ctx.drawImage(myBallImage, 0, 0, halfwidth*2, halfheight*2 );
            else
            if ( jellyObject.shape == "MYBOX" )
                ctx.drawImage(myBoxImage, 0, 0, halfwidth*2, halfheight*2 );
    
            ctx.restore();
            }
        }
    else
        {
        myBallImage = new Image();
        myBallImage.src = 'circle.gif';
    
        myBoxImage = new Image();
        myBoxImage.src = 'box.gif';
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a website http://www.ArenaText.com written in asp.net with Microsoft AJAX control toolkit. iPad
Working through the five minute Xtext tutorial (http://www.eclipse.org/Xtext/documentation/2_1_0/010-xtext-in-5-minutes.php) I get to Generating The Language
Working through this for fun: http://www.diku.dk/hjemmesider/ansatte/torbenm/Basics/ Example calculation of nullable and first uses a
Working on calling a C function from my asm project. I'm trying to push
Working through C++ Primer Plus and am trying to cin data to a dynamically
working with: ASP.net using VB.net connecting to MS SQL Server What I'm trying to
Working with MVC 2 ad with the help of some friends I thought all
Working with COM interop, I can call a managed function from within unmanaged code.
Working in C#, I need to find all local peaks in a List of
Working on THIS Page: newsite.702wedding.com/live/ Can't find where to remove the arrows at the

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.