문제

    OK so I have a few levels of a simple platform built out, 

so I just need some insight on how to assign images to bodies, and handle images, etc. The game is a simple platform game, with a ball as the palyer chacter and you have to try to reach the other side. I have some obstacles like joints and swinging balls, etc. Just getting it started, please let me know if you can help... box2dweb.. Here is an example of a few bodies inside my game in various places.. Any advice would be greatly appreciated. Pplayer character let me know if you can help.

function PC(gamePiece){
        if (gamePiece == 1) {
        var ballSd1 = new b2CircleDef();
            ballSd1.density = 1.1;
            ballSd1.radius = 22;
            ballSd1.restitution = 0.5;
            ballSd1.friction = 1;
            ballSd1.userData = 'player';
            var ballBd = new b2BodyDef();
            ballBd.linearDamping = .03;
            ballBd.allowSleep = false;
            ballBd.AddShape(ballSd1);
            ballBd.position.Set(40,0);
            player.object = world.CreateBody(ballBd);   
        }

ok so i am using box2d and need some help adding images to bodies...

도움이 되었습니까?

해결책

I guess you do not generate your world programmatically. You will need to find an editor suitable for this job, or write one yourself.

I can advice you to use R.U.B.E which lets you create your Box2D worlds and attach images to the bodies. You may then export the scene via JSON which fits very well to javascript.

The rendering of those images attached to bodies will be a custom job. As well as the importing of the scene if there is no loader for box2dweb yet.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top