The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Box2d with AS3
Posted by: Mek | February 19, 2010 @ 11:14am
ActionScript Code
[
Download
]
/* ==================== M A I N ======================= */ /* * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ package{ import Box2D.Dynamics.* import Box2D.Collision.* import Box2D.Collision.Shapes.* import Box2D.Dynamics.Joints.* import Box2D.Dynamics.Contacts.* import Box2D.Common.Math.* import flash.events.Event; import flash.display.*; import flash.text.*; import General.* import TestBed.*; import TestBed.TestBridge; import flash.display.MovieClip; public class Main extends MovieClip{ public function Main(){ addEventListener(Event.ENTER_FRAME, update, false, 0, true); m_fpsCounter.x = 7; m_fpsCounter.y = 5; addChildAt(m_fpsCounter, 0); m_sprite = new Sprite(); addChild(m_sprite); // input m_input = new Input(m_sprite); //Instructions Text var instructions_text:TextField = new TextField(); var instructions_text_format:TextFormat = new TextFormat("Arial", 16, 0xffffff, false, false, false); instructions_text_format.align = TextFormatAlign.RIGHT; instructions_text.defaultTextFormat = instructions_text_format instructions_text.x = 140 instructions_text.y = 4.5 instructions_text.width = 495 instructions_text.height = 61 instructions_text.text = "" addChild(instructions_text); // textfield pointer m_aboutText = new TextField(); var m_aboutTextFormat:TextFormat = new TextFormat("Arial", 16, 0x00CCFF, true, false, false); m_aboutTextFormat.align = TextFormatAlign.RIGHT; m_aboutText.defaultTextFormat = m_aboutTextFormat m_aboutText.x = 334 m_aboutText.y = 71 m_aboutText.width = 300 m_aboutText.height = 30 addChild(m_aboutText); // Thanks to everyone who contacted me about this fix instructions_text.mouseEnabled = false; m_aboutText.mouseEnabled = false; m_currTest = new TestCompound(4); } public function update(e:Event):void{ // clear for rendering m_sprite.graphics.clear() // toggle between tests if (Input.isKeyPressed(39)){ // Right Arrow m_currId++; m_currTest = null; } else if (Input.isKeyPressed(37)){ // Left Arrow m_currId--; m_currTest = null } // Reset else if (Input.isKeyPressed(82)){ // R m_currTest = null } else if (Input.isKeyPressed(103)){ // g m_currTest = new TestCompound(this.num_legs); } m_currTest = new TestCompound(this.num_legs); // update current test m_currTest.Update(); // Update input (last) Input.update(); // update counter and limit framerate m_fpsCounter.update(); FRateLimiter.limitFrame(30); } public function go (e:Event) :void { m_currTest = new TestCompound(this.num_legs); } //====================== // Member data //====================== static public var m_fpsCounter:FpsCounter = new FpsCounter(); public var m_currId:int = 0; public var m_currTest:Test; static public var m_sprite:Sprite; static public var m_aboutText:TextField; // input public var m_input:Input; } } /* ==================== T e s t C o m p o u n d ======================= */
Syntax Highlighting
[
Open in new window
]
Author Comments
The project is called PhysTest and in PhysTest there is a button called 'go'.
Rating
4.51 / 8
53 Votes
http://codebin.yi.org/511
page generated in 0.01 seconds