<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="sv">
	<id>https://wikiskola.se/index.php?action=history&amp;feed=atom&amp;title=Box2d_flash_bouyancy</id>
	<title>Box2d flash bouyancy - Versionshistorik</title>
	<link rel="self" type="application/atom+xml" href="https://wikiskola.se/index.php?action=history&amp;feed=atom&amp;title=Box2d_flash_bouyancy"/>
	<link rel="alternate" type="text/html" href="https://wikiskola.se/index.php?title=Box2d_flash_bouyancy&amp;action=history"/>
	<updated>2026-05-14T17:07:00Z</updated>
	<subtitle>Versionshistorik för denna sida på wikin</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wikiskola.se/index.php?title=Box2d_flash_bouyancy&amp;diff=12128&amp;oldid=prev</id>
		<title>Hakan den 1 mars 2012 kl. 00.28</title>
		<link rel="alternate" type="text/html" href="https://wikiskola.se/index.php?title=Box2d_flash_bouyancy&amp;diff=12128&amp;oldid=prev"/>
		<updated>2012-03-01T00:28:31Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;sv&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Äldre version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Versionen från 1 mars 2012 kl. 00.28&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Rad 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Rad 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;source lang=&quot;php&quot;&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;/*&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;/*&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l207&quot;&gt;Rad 207:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Rad 208:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/source&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Hakan</name></author>
	</entry>
	<entry>
		<id>https://wikiskola.se/index.php?title=Box2d_flash_bouyancy&amp;diff=12127&amp;oldid=prev</id>
		<title>Hakan: Skapade sidan med &#039;/* * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com * * This software is provided &#039;as-is&#039;, without any express or implied * warranty.  In no event will the authors...&#039;</title>
		<link rel="alternate" type="text/html" href="https://wikiskola.se/index.php?title=Box2d_flash_bouyancy&amp;diff=12127&amp;oldid=prev"/>
		<updated>2012-03-01T00:26:30Z</updated>

		<summary type="html">&lt;p&gt;Skapade sidan med &amp;#039;/* * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com * * This software is provided &amp;#039;as-is&amp;#039;, without any express or implied * warranty.  In no event will the authors...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ny sida&lt;/b&gt;&lt;/p&gt;&lt;div&gt;/*&lt;br /&gt;
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com&lt;br /&gt;
*&lt;br /&gt;
* This software is provided &amp;#039;as-is&amp;#039;, without any express or implied&lt;br /&gt;
* warranty.  In no event will the authors be held liable for any damages&lt;br /&gt;
* arising from the use of this software.&lt;br /&gt;
* Permission is granted to anyone to use this software for any purpose,&lt;br /&gt;
* including commercial applications, and to alter it and redistribute it&lt;br /&gt;
* freely, subject to the following restrictions:&lt;br /&gt;
* 1. The origin of this software must not be misrepresented; you must not&lt;br /&gt;
* claim that you wrote the original software. If you use this software&lt;br /&gt;
* in a product, an acknowledgment in the product documentation would be&lt;br /&gt;
* appreciated but is not required.&lt;br /&gt;
* 2. Altered source versions must be plainly marked as such, and must not be&lt;br /&gt;
* misrepresented as being the original software.&lt;br /&gt;
* 3. This notice may not be removed or altered from any source distribution.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
package TestBed{&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	import Box2D.Dynamics.*;&lt;br /&gt;
	import Box2D.Collision.*;&lt;br /&gt;
	import Box2D.Collision.Shapes.*;&lt;br /&gt;
	import Box2D.Dynamics.Joints.*;&lt;br /&gt;
	import Box2D.Dynamics.Contacts.*;&lt;br /&gt;
	import Box2D.Dynamics.Controllers.*;&lt;br /&gt;
	import Box2D.Common.*;&lt;br /&gt;
	import Box2D.Common.Math.*;&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	public class TestBuoyancy extends Test{&lt;br /&gt;
		&lt;br /&gt;
		private var m_bodies:Array = new Array();&lt;br /&gt;
		private var m_controller:b2Controller;&lt;br /&gt;
		&lt;br /&gt;
		public function TestBuoyancy(){&lt;br /&gt;
			var bc:b2BuoyancyController = new b2BuoyancyController();&lt;br /&gt;
			m_controller = bc;&lt;br /&gt;
			&lt;br /&gt;
			bc.normal.Set(0,-1);&lt;br /&gt;
			bc.offset = -200 / m_physScale;&lt;br /&gt;
			bc.density = 2.0;&lt;br /&gt;
			bc.linearDrag = 5;&lt;br /&gt;
			bc.angularDrag = 2;&lt;br /&gt;
			&lt;br /&gt;
			var ground:b2Body = m_world.GetGroundBody();&lt;br /&gt;
			var i:int;&lt;br /&gt;
			var anchor:b2Vec2 = new b2Vec2();&lt;br /&gt;
			var body:b2Body;&lt;br /&gt;
			var fd:b2FixtureDef;&lt;br /&gt;
			&lt;br /&gt;
			// Spawn in a bunch of crap&lt;br /&gt;
			for (i = 0; i &amp;lt; 5; i++){&lt;br /&gt;
				var bodyDef:b2BodyDef = new b2BodyDef();&lt;br /&gt;
				bodyDef.type = b2Body.b2_dynamicBody;&lt;br /&gt;
				//bodyDef.isBullet = true;&lt;br /&gt;
				var boxDef:b2PolygonShape = new b2PolygonShape();&lt;br /&gt;
				fd = new b2FixtureDef();&lt;br /&gt;
				fd.shape = boxDef;&lt;br /&gt;
				fd.density = 1.8;&lt;br /&gt;
				// Override the default friction.&lt;br /&gt;
				fd.friction = 0.3;&lt;br /&gt;
				fd.restitution = 0.1;&lt;br /&gt;
				boxDef.SetAsBox((Math.random() * 5 + 10) / m_physScale, (Math.random() * 5 + 10) / m_physScale);&lt;br /&gt;
				bodyDef.position.Set((Math.random() * 400 + 120) / m_physScale, (Math.random() * 150 + 50) / m_physScale);&lt;br /&gt;
				bodyDef.angle = Math.random() * Math.PI;&lt;br /&gt;
				body = m_world.CreateBody(bodyDef);&lt;br /&gt;
				body.CreateFixture(fd);&lt;br /&gt;
				m_bodies.push(body);&lt;br /&gt;
				&lt;br /&gt;
			}&lt;br /&gt;
			for (i = 0; i &amp;lt; 5; i++){&lt;br /&gt;
				var bodyDefC:b2BodyDef = new b2BodyDef();&lt;br /&gt;
				bodyDefC.type = b2Body.b2_dynamicBody;&lt;br /&gt;
				//bodyDefC.isBullet = true;&lt;br /&gt;
				var circDef:b2CircleShape= new b2CircleShape((Math.random() * 5 + 10) / m_physScale);&lt;br /&gt;
				fd = new b2FixtureDef();&lt;br /&gt;
				fd.shape = circDef;&lt;br /&gt;
				fd.density = 0.06;&lt;br /&gt;
				// Override the default friction.&lt;br /&gt;
				fd.friction = 0.3;&lt;br /&gt;
				fd.restitution = 0.1;&lt;br /&gt;
				bodyDefC.position.Set((Math.random() * 400 + 120) / m_physScale, (Math.random() * 150 + 50) / m_physScale);&lt;br /&gt;
				bodyDefC.angle = Math.random() * Math.PI;&lt;br /&gt;
				body = m_world.CreateBody(bodyDefC);&lt;br /&gt;
				body.CreateFixture(fd);&lt;br /&gt;
				m_bodies.push(body);&lt;br /&gt;
			}&lt;br /&gt;
			for (i = 0; i &amp;lt; 15; i++){&lt;br /&gt;
				var bodyDefP:b2BodyDef = new b2BodyDef();&lt;br /&gt;
				bodyDefP.type = b2Body.b2_dynamicBody;&lt;br /&gt;
				//bodyDefP.isBullet = true;&lt;br /&gt;
				var polyDef:b2PolygonShape = new b2PolygonShape();&lt;br /&gt;
				if (Math.random() &amp;gt; 0.66) {&lt;br /&gt;
					polyDef.SetAsArray([&lt;br /&gt;
						new b2Vec2((-10 -Math.random()*10) / m_physScale, ( 10 +Math.random()*10) / m_physScale),&lt;br /&gt;
						new b2Vec2(( -5 -Math.random()*10) / m_physScale, (-10 -Math.random()*10) / m_physScale),&lt;br /&gt;
						new b2Vec2((  5 +Math.random()*10) / m_physScale, (-10 -Math.random()*10) / m_physScale),&lt;br /&gt;
						new b2Vec2(( 10 +Math.random() * 10) / m_physScale, ( 10 +Math.random() * 10) / m_physScale)&lt;br /&gt;
						]);&lt;br /&gt;
				}&lt;br /&gt;
				else if (Math.random() &amp;gt; 0.5) &lt;br /&gt;
				{&lt;br /&gt;
					var array:Array = [];&lt;br /&gt;
					array[0] = new b2Vec2(0, (10 +Math.random()*10) / m_physScale);&lt;br /&gt;
					array[2] = new b2Vec2((-5 -Math.random()*10) / m_physScale, (-10 -Math.random()*10) / m_physScale);&lt;br /&gt;
					array[3] = new b2Vec2(( 5 +Math.random()*10) / m_physScale, (-10 -Math.random()*10) / m_physScale);&lt;br /&gt;
					array[1] = new b2Vec2((array[0].x + array[2].x), (array[0].y + array[2].y));&lt;br /&gt;
					array[1].Multiply(Math.random()/2+0.8);&lt;br /&gt;
					array[4] = new b2Vec2((array[3].x + array[0].x), (array[3].y + array[0].y));&lt;br /&gt;
					array[4].Multiply(Math.random() / 2 + 0.8);&lt;br /&gt;
					polyDef.SetAsArray(array);&lt;br /&gt;
				}&lt;br /&gt;
				else &lt;br /&gt;
				{&lt;br /&gt;
					polyDef.SetAsArray([&lt;br /&gt;
						new b2Vec2(0, (10 +Math.random()*10) / m_physScale),&lt;br /&gt;
						new b2Vec2((-5 -Math.random()*10) / m_physScale, (-10 -Math.random()*10) / m_physScale),&lt;br /&gt;
						new b2Vec2(( 5 +Math.random() * 10) / m_physScale, ( -10 -Math.random() * 10) / m_physScale)&lt;br /&gt;
					]);&lt;br /&gt;
				}&lt;br /&gt;
				fd = new b2FixtureDef();&lt;br /&gt;
				fd.shape = polyDef;&lt;br /&gt;
				fd.density = 2.1;&lt;br /&gt;
				fd.friction = 0.3;&lt;br /&gt;
				fd.restitution = 0.1;&lt;br /&gt;
				bodyDefP.position.Set((Math.random() * 400 + 120) / m_physScale, (Math.random() * 150 + 50) / m_physScale);&lt;br /&gt;
				bodyDefP.angle = Math.random() * Math.PI;&lt;br /&gt;
				body = m_world.CreateBody(bodyDefP);&lt;br /&gt;
				body.CreateFixture(fd);&lt;br /&gt;
				m_bodies.push(body);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			//Add some exciting bath toys&lt;br /&gt;
			boxDef.SetAsBox(40 / m_physScale, 10 / m_physScale);&lt;br /&gt;
			fd = new b2FixtureDef();&lt;br /&gt;
			fd.shape = boxDef;&lt;br /&gt;
			fd.density = 3.0;&lt;br /&gt;
			bodyDef.position.Set(50 / m_physScale, 300 / m_physScale);&lt;br /&gt;
			bodyDef.angle = 0;&lt;br /&gt;
			body = m_world.CreateBody(bodyDef);&lt;br /&gt;
			body.CreateFixture(fd);&lt;br /&gt;
			m_bodies.push(body);&lt;br /&gt;
			&lt;br /&gt;
			bodyDef.position.Set(300/ m_physScale, 300 / m_physScale);&lt;br /&gt;
			body = m_world.CreateBody(bodyDef);&lt;br /&gt;
			circDef = new b2CircleShape(7 / m_physScale);&lt;br /&gt;
			fd = new b2FixtureDef();&lt;br /&gt;
			fd.shape = circDef;&lt;br /&gt;
			fd.density =2.0;&lt;br /&gt;
			circDef.b2internal::m_p.Set(30 / m_physScale, 0 / m_physScale);&lt;br /&gt;
			body.CreateFixture(fd);&lt;br /&gt;
			circDef.b2internal::m_p.Set(-30 / m_physScale, 0 / m_physScale);&lt;br /&gt;
			body.CreateFixture(fd);&lt;br /&gt;
			circDef.b2internal::m_p.Set(0 / m_physScale, 30 / m_physScale);&lt;br /&gt;
			body.CreateFixture(fd);&lt;br /&gt;
			circDef.b2internal::m_p.Set(0 / m_physScale, -30 / m_physScale);&lt;br /&gt;
			body.CreateFixture(fd);&lt;br /&gt;
			&lt;br /&gt;
			fd = new b2FixtureDef();&lt;br /&gt;
			fd.shape = boxDef;&lt;br /&gt;
			fd.density = 2.0;&lt;br /&gt;
			boxDef.SetAsBox(30 / m_physScale, 2 / m_physScale);&lt;br /&gt;
			body.CreateFixture(fd);&lt;br /&gt;
			fd.density = 2.0;&lt;br /&gt;
			boxDef.SetAsBox(2 / m_physScale, 30 / m_physScale);&lt;br /&gt;
			body.CreateFixture(fd);&lt;br /&gt;
			m_bodies.push(body);&lt;br /&gt;
			&lt;br /&gt;
			for each(body in m_bodies)&lt;br /&gt;
				m_controller.AddBody(body);&lt;br /&gt;
			m_world.AddController(m_controller);&lt;br /&gt;
			&lt;br /&gt;
			// Set Text field&lt;br /&gt;
			Main.m_aboutText.text = &amp;quot;Buoyancy&amp;quot;;&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		//======================&lt;br /&gt;
		// Member Data &lt;br /&gt;
		//======================&lt;br /&gt;
		&lt;br /&gt;
		public override function Update():void{&lt;br /&gt;
			&lt;br /&gt;
			super.Update();&lt;br /&gt;
			//Draw water line&lt;br /&gt;
			m_sprite.graphics.lineStyle(1,0x0000ff,1);&lt;br /&gt;
			m_sprite.graphics.moveTo(5,200);&lt;br /&gt;
			m_sprite.graphics.lineTo(635,200);&lt;br /&gt;
			//It&amp;#039;s not water without transparency...&lt;br /&gt;
			m_sprite.graphics.lineStyle();&lt;br /&gt;
			m_sprite.graphics.beginFill(0x0000ff,0.2);&lt;br /&gt;
			m_sprite.graphics.moveTo(5,200);&lt;br /&gt;
			m_sprite.graphics.lineTo(635,200);&lt;br /&gt;
			m_sprite.graphics.lineTo(635,355);&lt;br /&gt;
			m_sprite.graphics.lineTo(5,355);&lt;br /&gt;
			m_sprite.graphics.endFill();&lt;br /&gt;
&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Hakan</name></author>
	</entry>
</feed>