Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-23-2012, 03:58 PM   #1
pixrael
Registered User
 
Join Date: Jun 2011
Posts: 24
Default [AS3] box2d, car game

Hi everybody.

here is these wonderful examples

emanueleferonato dot com/2009/04/06/two-ways-to-make-box2d-cars

ok what mi trying to do is add some skin to the ground and car, but i dont know how, here are other samples where objects have skins

box2d dot org/forum/viewtopic.php?f=3&t=6297

but still it doesnt work, do u know how to put the skin in box2D?

sorry about the links i cant post them until have 50 or greater post.
pixrael is offline   Reply With Quote
Old 05-23-2012, 04:01 PM   #2
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

You should follow my tutorial here:
http://www.actionscript.org/resource...x2D/Page1.html
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 05-23-2012, 05:17 PM   #3
dialectric
Senior Member
 
dialectric's Avatar
 
Join Date: May 2006
Location: USA
Posts: 614
Default

Hi,

If you are already using emanuele feronato's site, you might find the other examples for box2d helpful for skinning. This one deals with it specifically:

http://www.emanueleferonato.com/2011...inning-crates/

- dialectric
dialectric is offline   Reply With Quote
Old 05-23-2012, 07:54 PM   #4
pixrael
Registered User
 
Join Date: Jun 2011
Posts: 24
Question

Thank ASWC and Dialectric for your quick answer.


I still i've not see the ASWC, but i will by finishing this post, i just wanted post first.


Dialectric i've seen the other samples and basicly the thing is (or what i understand) to add new object of the MC with the skin through the "userData" to the b2BodyDef object. And then in the update function every change applied to the object must be applied to the skin too.

Code:
         //adding the skin wheel to the object
         bodyDef.userData = new wheel();
	 bodyDef.userData.width = 10 * .25 * 30;
	 bodyDef.userData.height = 10 * .25 * 30;
         body = world.CreateBody(bodyDef);
in the update function:


Code:
//apply the changes to every skin of every object
for (var bb:b2Body = world.m_bodyList; bb; bb = bb.m_next) {
	if (bb.m_userData is Sprite ) {
		bb.m_userData.x = bb.GetPosition().x * pixels_in_a_meter;
		bb.m_userData.y = bb.GetPosition().y * pixels_in_a_meter;
		bb.m_userData.rotation = bb.GetAngle() * (180 / Math.PI);
	}
 }

If u see something missing please help, for now i will see the ASWC tutorial then ill tell what was my problem, i hope it solves.
pixrael is offline   Reply With Quote
Old 05-25-2012, 04:29 PM   #5
pixrael
Registered User
 
Join Date: Jun 2011
Posts: 24
Default my skin moves apart

the ASWC tutorial of box2d is amazin! thanks

now i know how to add a skin to the stage but still i have this problems:
1-the skin goes apart of the object im applying the skin
2-I dont know how a the he.. add the skin for the wheels.

here is the .fla where u can see all
wwwDOTmediafireDOTcom/file/ujernnkd6s99099/SkinTestDOTrar

any ideas? thanks

Last edited by pixrael; 05-25-2012 at 04:31 PM. Reason: correcting letters
pixrael is offline   Reply With Quote
Old 05-28-2012, 03:29 PM   #6
pixrael
Registered User
 
Join Date: Jun 2011
Posts: 24
Default finally i found my error

well the thing is that i was adding child to the stage and not to the "screen" movie clip, so when i add it it just move independent of the correct object.

here is the fla where u can download the progress, it has the ground skinned and the truck except the wheels skinned.

mediafireDOTcom/?ellduquvzag9ivu

next is to skin the wheel i hope no be a problem.

again thanks to ASWC and Dialectric for all.
pixrael is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:28 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.