当前位置: 首页 > news >正文

营销型网站设计案例wordpress客户留言插件

营销型网站设计案例,wordpress客户留言插件,网站网页设计怎么收费,义乌网站建站作者#xff1a;Emanuele Feronato随着《Angry Birds Space》的问世#xff0c;我想你定非常疑惑要如何通过Box2D模拟星球重力。基本原理非常简单。首先#xff0c;太空没有重力#xff0c;所以你将通过如下方式创建没有重力的b2World世界#xff1a;private var world:b2…作者Emanuele Feronato随着《Angry Birds Space》的问世我想你定非常疑惑要如何通过Box2D模拟星球重力。基本原理非常简单。首先太空没有重力所以你将通过如下方式创建没有重力的b2World世界private var world:b2Worldnew b2World(new b2Vec2(0,0),true);abspace from emanueleferonato.com接着就是根据主体和球体位置落实Force。参考如下脚本package {import flash.display.Sprite;import flash.events.Event;import flash.events.MouseEvent;import Box2D.Dynamics.*;import Box2D.Collision.*;import Box2D.Collision.Shapes.*;import Box2D.Common.Math.*;import Box2D.Dynamics.Joints.*;public class Main extends Sprite {private var world:b2Worldnew b2World(new b2Vec2(0,0),true);private var worldScale:Number30;private var planetVector:Vector.new Vector.();private var debrisVector:Vector.new Vector.();private var orbitCanvas:Spritenew Sprite();public function Main() {addChild(orbitCanvas);orbitCanvas.graphics.lineStyle(1,0xff0000);debugDraw();addPlanet(180,240,90);addPlanet(480,120,45);addEventListener(Event.ENTER_FRAME,update);stage.addEventListener(MouseEvent.CLICK,createDebris);}private function createDebris(e:MouseEvent):void {addBox(mouseX,mouseY,20,20);}private function addPlanet(pX:Number,pY:Number,r:Number):void {var fixtureDef:b2FixtureDef new b2FixtureDef();fixtureDef.restitution0;fixtureDef.density1;var circleShape:b2CircleShapenew b2CircleShape(r/worldScale);fixtureDef.shapecircleShape;var bodyDef:b2BodyDefnew b2BodyDef();bodyDef.userDatanew Sprite();bodyDef.position.Set(pX/worldScale,pY/worldScale);var thePlanet:b2Bodyworld.CreateBody(bodyDef);planetVector.push(thePlanet);thePlanet.CreateFixture(fixtureDef);orbitCanvas.graphics.drawCircle(pX,pY,r*3);}private function addBox(pX:Number,pY:Number,w:Number,h:Number):void {var polygonShape:b2PolygonShape new b2PolygonShape();polygonShape.SetAsBox(w/worldScale/2,h/worldScale/2);var fixtureDef:b2FixtureDef new b2FixtureDef();fixtureDef.density1;fixtureDef.friction1;fixtureDef.restitution0;fixtureDef.shapepolygonShape;var bodyDef:b2BodyDef new b2BodyDef();bodyDef.typeb2Body.b2_dynamicBody;bodyDef.position.Set(pX/worldScale,pY/worldScale);var box:b2Bodyworld.CreateBody(bodyDef);debrisVector.push(box);box.CreateFixture(fixtureDef);}private function debugDraw():void {var debugDraw:b2DebugDraw new b2DebugDraw();var debugSprite:Sprite new Sprite();addChild(debugSprite);debugDraw.SetSprite(debugSprite);debugDraw.SetDrawScale(worldScale);debugDraw.SetFlags(b2DebugDraw.e_shapeBit|b2DebugDraw.e_jointBit);debugDraw.SetFillAlpha(0.5);world.SetDebugDraw(debugDraw);}private function update(e:Event):void {world.Step(1/30, 10, 10);world.ClearForces();for (var i:int0; ivar debrisPosition:b2Vec2debrisVector[i].GetWorldCenter();for (var j:int0; jvar planetShape:b2CircleShapeplanetVector[j].GetFixtureList().GetShape() as b2CircleShape;var planetRadius:NumberplanetShape.GetRadius();var planetPosition:b2Vec2planetVector[j].GetWorldCenter();var planetDistance:b2Vec2new b2Vec2(0,0);planetDistance.Add(debrisPosition);planetDistance.Subtract(planetPosition);var finalDistance:NumberplanetDistance.Length();if (finalDistanceplanetRadius*3) {planetDistance.NegativeSelf();var vecSum:NumberMath.abs(planetDistance.x)Math.abs(planetDistance.y);planetDistance.Multiply((1/vecSum)*planetRadius/finalDistance);debrisVector[i].ApplyForce(planetDistance,debrisVector[i].GetWorldCenter());}}}world.DrawDebugData();}}}整个代码只创造静态主体(星球)让你通过点击鼠标放置动态主体(碎屑)。脚本的唯一有趣之处在于更新函数的循环语句下面我将逐行进行解释。for (var i:int0; i检测之前存储于矢量Vector中的所有碎屑的循环语句在第14行代码中呈现在第54行进行更新。var debrisPosition:b2Vec2debrisVector[i].GetWorldCenter();设定碎屑位置。for (var j:int0; j检测之前存储于矢量Vector中的所有星球的循环语句将在第13行代码中呈现在第38行进行更新。var planetShape:b2CircleShapeplanetVector[j].GetFixtureList().GetShape() as b2CircleShape;我需要知道星球的质量因为质量越大重力吸引力就越强烈。遗憾的是Box2D静态主体没有质量所以我需要得到星球的圆形模型……var planetRadius:NumberplanetShape.GetRadius();……设定它的半径。所以在这种情况下半径越大重力吸引力就越强烈。var planetPosition:b2Vec2planetVector[j].GetWorldCenter();设定星球的位置。var planetDistance:b2Vec2new b2Vec2(0,0);创建新的b2Vec2变量它将存储星球和碎屑之间的距离。planetDistance.Add(debrisPosition);添加碎屑坐标轴然后……planetDistance.Subtract(planetPosition);……扣除星球坐标轴。var finalDistance:NumberplanetDistance.Length();计算星球和碎屑之间的距离。if (finalDistanceplanetRadius*3) {检查碎屑是否受到星球重力的影响(游戏邦注这里碎屑的半径不能大于星球半径的3倍)。planetDistance.NegativeSelf();插入星球距离这样force会按照星球起点的方向移动碎屑。var vecSum:NumberMath.abs(planetDistance.x)Math.abs(planetDistance.y);合计距离矢量分量。因此碎屑远离星球时重力吸引力应减弱碎屑靠近星球时重力吸引力应增强。planetDistance.Multiply((1/vecSum)*planetRadius/finalDistance);这是随着我们逐步远离星球削弱重力的最后公式。debrisVector[i].ApplyForce(planetDistance,debrisVector[i].GetWorldCenter());最终force将被运用至碎屑中。下面是最终结果debris from emanueleferonato.com(本文为游戏邦/gamerboom.com编译拒绝任何不保留版权的转载如需转载请联系游戏邦)Simulate radial gravity (also known as “planet gravity”) with Box2D as seen on Angry Birds Spaceby Emanuele FeronatoWith the launch of Angry Birds Space I am sure you are wondering how to simulate planet gravity with Box2D.And guess what… the basics are very easy.First, in space there’s no gravity, so you will create a b2World world without gravity this way:Then, it’s just a matter of applying Forces according to bodies and planets position.Look at this script:The whole code just create static bodies (planets) and let you place dynamic bodies (debris) with the click of the mouse.The only interesting part of the script is the for loop in the update function, which I’ll explain line by line:Loop which scans for all debris previously stored in debrisVector Vector declared at line 14 and updated at line 54Gets debris positionLoop which scans for all planets previously stored in planetVector Vector declared at line 13 and updated at line 38I need to know the mass of the planet because the bigger the mass, the more intense the gravity attraction. Unfortunately Box2D static bodies do not have mass, so I need to get the circle shape of the planet…… and get its radius. So in this case the bigger the radius, the more intense the gravity attractionGets planet positionCreates a new b2Vec2 variable which will store the distance between the planet and the debrisAdds debris coordinates, then…… subtracts planet coordinatesCalculates the distance between the planet and the debrisChecks if the debris should be affected by planet gravity (in this case, the debris must be within a radius of three times the planet radius)Inverts planet distance, so that the force will move the debris in the direction of the planet originGets the sum of distance vector components. I will need this to make gravity attraction weaker when the debris is far from the planet, and stronger when the debris is getting close to the planetThis is the final formula to make the gravity weaker as we move far from the planetAnd finally the force can be applied to debrisThis is the result:(Sourceemanueleferonato)
http://www.yutouwan.com/news/362092/

相关文章:

  • 广东做网站公司东莞头条最近15天新闻
  • 网站建设灬金手指下拉十四用糖做的网站
  • 扬州建设公司网站益阳做网站
  • 网站开发设计总结及心得体会哪个网站专业做饲料
  • 个人网站做什么内容网站如何调用百度地图
  • 珠海电商网站制作私自建立网站网站判决书
  • 一个网站怎么赚钱网站建设关键性开发工具
  • 免费域名注册和免费建站滨州做网站的公司
  • 网站规划与建设的流程与方法 高中信息技术wordpress博客vieu模板
  • 网站建设前的分析第一小节内容做动态文字的网站
  • 网络网站设计培训如何自己做网站并开发软件
  • 成都建站培训seo外链查询工具
  • 视频播放网站建设手机版网站快照如何做
  • 网站如何做网页查询网络服务公司名字
  • 河南seo网站开发网站建设的基本术语
  • 网站建设前准备做的网站怎么联网
  • php网站修改主页内容注册公司需要登录的网址
  • 宁波网站建设开发多少钱网页制作的论文
  • 网站设置价格错误不愿意发货常用网站建设技术是什么意思
  • wordpress主题 网站大全刚成立公司如何做网站
  • 龙口建网站公司价格如何做网站栏目
  • 如何修改网站模版阿里云建设网站买哪个服务
  • 网站制作wordpress外网访问群晖wordpress
  • 艺术视频手机网站可以做吗中高端社交网站建设服务商
  • 创意网站设计团队如何做企业交易网站
  • 企业网站备案 优帮云WordPress火车头规则
  • 网站互动方式钦州建设银行社招聘网站
  • 公司备案号查询网站wordpress163邮件
  • 有了域名 接下来怎么做网站别墅设计 网站模板
  • 响水网站建设找哪家好关键词推广数据分析