旋转的月亮动画2-通过复制像素创建动画

[color="#c0c0c0"]Creating animation by copying pixels[/color]
通过复制点创建动画
[color="#c0c0c0"]A basic definition of animation is the illusion of motion, or change, created by changing an image over time.
[/color]
动画的一个基本定义是通过在一定时间内改变或移动图像而产生的幻觉。
[color="#c0c0c0"]In this sample, the goal is to create the illusion of a spherical moon rotating around its vertical axis.
[/color]
在本例中,目标是创建球状的月亮在它竖直轴附近转动的幻觉影像。
[color="#c0c0c0"]However, for the purposes of the animation, you can ignore the spherical distortion aspect of the sample.
[/color]
但是,为了动画的目的,你可以忽略例子的球状变形的问题
[color="#c0c0c0"]Consider the actual image that’s loaded and used as the source of the moon image data:
[/color]
考虑到实际加载并使用的图像是这样的月亮图像
[img]/uploads/allimg/080326/1821270.jpg[/img]
[color="#c0c0c0"]As you can see, the image is not one or several spheres; it’s a rectangular photograph of the surface of the moon.
[/color]
就像你看到的,图像不是一个或几个面,它是一个长方形的月亮表面的图像
[color="#c0c0c0"]Because the photo was taken exactly at the moon’s equator,
[/color]
因为,图像是从月亮的赤道上方拍摄来的
[color="#c0c0c0"]the parts of the image that are closer to the top and bottom of the image are stretched and distorted.
[/color]
部分靠近顶端和底端图像是变形了的图像
[color="#c0c0c0"]To remove the distortion from the image and make it appear spherical, we will use a displacementmap filter, as described later.
[/color]
为了消除变形,使其看上去像个球,我们将用到一个像后面描述的displacementmap过滤器,
[color="#c0c0c0"]However, because this source image is a rectangle, to create the illusion that the sphere is rotating, the code simply needs to slide the moon surface photo horizontally, as described in the following paragraphs.
[/color]
尽管如此,因为源图像是个长方形,为了创建创建球型转动的幻觉,代码需要将月球表面照片转换成地平面。下文详谈。
[color="#c0c0c0"]Notice that the image actually contains two copies of the moon surface photograph next to each other.
[/color]
注意 图像实际上包含月亮表面图像的两个copy
[color="#c0c0c0"]This image is the source image from which image data is copied repeatedly to
create the appearance of motion.
[/color]
这个图像是用来创建月亮外貌的源数据
[color="#c0c0c0"]By having two copies of the image next to each other, a continuous, uninterrupted scrolling effect can more easily be created.
[/color]
把图像的复制一个在它的旁边,有利于创建旋转效果。
[color="#c0c0c0"]Let’s walk through the process of the animation step-by-step to see how this works.
[/color]
让我们通过看动画制作的一个个步骤来理解其原理
[color="#c0c0c0"]The process actually involves two separate ActionScript objects.
[/color]
整个步骤实际上包含了两个相对独立的ActionScript对象(模块)
[color="#c0c0c0"]First, there is the loaded source image, which in the code is represented by the BitmapData instance named textureMap.
[/color]
首先,有个被加载的源图像,在代码中它被存储在BitmapData类型变量textureMap中
[color="#c0c0c0"]As described previously, textureMap is populated with image data as soon as the
external image loads, using this code:
[/color]
就像前面讨论的,textureMap是在图像加载完毕的时候被赋值的,下面是代码:
[color="#c0c0c0"]textureMap = event.target.content.bitmapData;The content of textureMap is the image shown previously.
[/color]
textureMap的内容就是前面展示过的那图像
[color="#c0c0c0"]In addition, to create the animated rotation,
[/color]
另外为了创建真实的旋转效果
[color="#c0c0c0"]the sample uses a Bitmap instance named, which is the actual display object that shows the moon image onscreen.
[/color]
例中使用了一个叫sphere的Bitmap类型变量,它是真正把图像显示在屏幕上的量
[color="#c0c0c0"]Like textureMap, the sphere object is created and populated with its initial image data in the imageLoadComplete() method, using the following code:
[/color]
就像textureMap类似,sphere对象在imageLoadComplete()函数中初始化图像数据,下面是代码
[color="#ff6600"]sphere = new Bitmap();
sphere.bitmapData = new BitmapData(textureMap.width / 2,textureMap.height);
sphere.bitmapData.copyPixels(textureMap,new Rectangle(0, 0, sphere.width, phere.height),new Point(0, 0));
[/color]
本文转自:http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/515.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值