几个有用的数学公式 for ActionScript 3
来源:互联网 发布:淘宝评语怎么修改 编辑:程序博客网 时间:2024/05/13 17:46
1.Distance Between Two Points 两点间的距离
dx = x2 – x1;dy = y2 – y1;dist = Math.sqrt(dx*dx + dy*dy);
2. Inching Formulas 缓动公式
sprite.x += (targetX - sprite.x) * easing;//easing: inching coefficientsprite.y += (targetY - sprite.y) * easing;
3. Elastic Formulas 弹性公式
vx += (targetX - sprite.x) * spring; //spring: elastic coefficientvy += (targetY - sprite.y) * spring;sprite.x += (vx *= friction); //friction: friction forcesprite.y += (vy *= friction);
4. Flexible Partial Shifts Formulas 柔性物体变换公式
var dx:Number = sprite.x - fixedX;var dy:Number = sprite.y - fixedY;var angle:Number = Math.atan2(dy, dx);var targetX:Number = fixedX + Math.cos(angle) * springLength;var targetY:Number = fixedX + Math.sin(angle) * springLength;
5. Rotation With Mouse Formulas 跟随鼠标转动
dx = mouseX - sprite.x;dy = mouseY - sprite.y;sprite.rotation = Math.atan2(dy, dx) * 180 / Math.PI;
6. Waveform Formulas 波形公式
public function onEnterFrame1(event:Event):void {ball.y=centerScale+Math.sin(angle)*range;angle+=speed;}
7. Heartthrob Formulas 心跳公式
public function onEnterFrame1(event:Event):void {ball.scaleX=centerScale+Math.sin(angle)*range;ball.scaleY=centerScale+Math.sin(angle)*range;angle+=speed;}
8. Circle Rotation Formulas 公转公式
public function onEnterFrame(event:Event):void {ball.x=centerX+Math.cos(angle)*radius;ball.y=centerY+Math.sin(angle)*radius;angle+=speed;}
9. Get Circle Area 获取圆周区域
public function getArea():Number{// The formula is Pi times the radius squared.return Math.PI * Math.pow((width / 2), 2);}
10. Get Circumference Ratio 获取圆周长度
public function getCircumference():Number{// The formula is Pi times the diameter.return Math.PI * width;}
11. Elliptic Rotation Formulas 椭圆公转
public function onEnterFrame(event:Event):void {ball.x=centerX+Math.cos(angle)*radiusX;ball.y=centerY+Math.sin(angle)*radiusY;angle+=speed;}
12. Color operations 颜色操作,获取alpha值
var t:uint=0×77ff8877;var s:uint=0xff000000;var h:uint=t&s;var m:uint=h>>24;trace(m);
13. Hex to Decimal 16进制转10进制
trace(hexValue);
14. Decimal to Hex 10进制转16进制
decimalValue.toString(16);
15. Pick Up Color 颜色拾取
red = color24 >> 16;green = color24 >> 8 & 0xFF;blue = color24 & 0xFF;alpha = color32 >> 24;red = color32 >> 16 & 0xFF;green = color32 >> 8 & 0xFF;blue = color232 & 0xFF;
16. Color Bit Arithmetic 颜色位运算
color24 = red << 16 | green << 8 | blue;color32 = alpha << 24 | red << 16 | green << 8 | blue;
from:16 Useful Mathematical Formulas In ActionScript 3
- 几个有用的数学公式 for ActionScript 3
- 几个有用的数学公式 for ActionScript 3
- ActionScript 3 开发的几个注意点
- 几个有用的网站
- 几个有用的过滤器
- 几个有用的sql
- 几个有用的网址~~
- 几个有用的代码
- 几个有用的超链接
- 有用的几个网址
- 几个有用的网址
- 几个有用的链接
- 几个有用的函数:
- 几个有用的网站
- 几个有用的链接
- 几个有用的宏
- 几个有用的宏
- 几个有用的宏
- 保存程序配置的方法:保存到注册表里 - C#
- rtt粒子渲染不正常的一系列问题
- mymemcpy
- POJ 1068 括号模拟
- .Net (C#)委托和事件(将方法作为方法的参数)
- 几个有用的数学公式 for ActionScript 3
- 离开
- 我的第一篇博文是关于粗心的!
- 如何动态删除Ext.TabPanel中的Items
- 多线程同步 CriticalSection(临界区)
- JAVA之——字符串
- 微博易物!Livlis.com:基于Twitter的易货交易服务
- 湿答答
- Ubuntu 10.04 之JDK安装