---
title: "AS3IsoLib isometric 游戏引擎教程"
author: "wgcode"
date: "2010-11-25T19:35:48Z"
tags: []
categories: ["编程语言"]
slug: "as3isolib-isometric"
draft: false
lastmod: "2010-11-25T19:35:48Z"
id: 824825
url: "https://tts.iteye.com/blog/824825"
---

AS3IsoLib 游戏列表 

 

[AS3IsoLib](http://www.brighthub.com/link/link.aspx?u=http%3A%2F%2Fcode.google.com%2Fp%2Fas3isolib%2F&p=61827) 让开发者更方便地创建3D开发的引擎！

- [Getting Started](http://www.bukisa.com/articles/231298_as3isolib-tutorial-series-getting-started) \[[DEMO](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61825.aspx)] \[[CODE](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61826.aspx)]
- [Moving Blocks](http://www.bukisa.com/articles/231405_as3isolib-tutorial-series-moving-boxes) \[[DEMO](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61841.aspx)] \[[CODE](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61842.aspx)]
- [Materials](http://www.bukisa.com/articles/231418_as3isolib-tutorial-series-materials) \[[DEMO](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61851.aspx)] \[[CODE](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61853.aspx)]
- [Height](http://www.bukisa.com/articles/231801_as3isolib-tutorial-series-height) \[[DEMO](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61938.aspx)] \[[CODE](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61939.aspx)]
- [Camera](http://www.bukisa.com/articles/231855_as3isolib-tutorial-series-camera) \[[DEMO](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61943.aspx)] \[[CODE](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61944.aspx)]
- [Interactivity](http://www.bukisa.com/articles/231927_as3isolib-tutorial-series-interaction) \[[DEMO](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61953.aspx)] \[[CODE](http://www.brighthub.com/hubfolio/matthew-casperson/media/p/61954.aspx)]

 

[**去到导航页**](http://www.brighthub.com/hubfolio/matthew-casperson/blog/archive/2009/08/23/tutorial-index.aspx)

**[![as3isolib logo main](http://www.lufree.com/wp-content/uploads/auto_save_image/2010/08/010726sXS.jpg "as3isolib logo main")](http://www.brighthub.com/bh_controls/viewarticleimage.aspx?url=http%3A%2F%2Fimages.brighthub.com%2FE0%2F6%2FE06782A791601B3179621F30E63A7B0049508854_large.jpg&title=as3isolib%20logo%20main)[![origin](http://www.lufree.com/wp-content/uploads/auto_save_image/2010/08/010726AJQ.jpg "origin")](http://www.brighthub.com/bh_controls/viewarticleimage.aspx?url=http%3A%2F%2Fimages.brighthub.com%2FCE%2FA%2FCEA3A165D4F8C7A7BFAFA875AE45A4D49AACB482_large.jpg&title=origin)[![texture](http://www.lufree.com/wp-content/uploads/auto_save_image/2010/08/010726c1T.jpg "texture")](http://www.brighthub.com/bh_controls/viewarticleimage.aspx?url=http%3A%2F%2Fimages.brighthub.com%2F17%2F3%2F17321087DB8B02966D03F5B406E13864B3DB0A31_large.jpg&title=texture)**

先来个最简单 最基础的

package 

{

        import as3isolib.display.primitive.IsoBox;

        import as3isolib.display.scene.IsoScene;

        

        import flash.display.Sprite;

        

        public class IsoApplication extends Sprite

        {

                public function IsoApplication ()

                {

                        var box:IsoBox = new IsoBox();

                        box.setSize(25, 25, 25);

                        box.moveTo(200, 0, 0);

                        var scene:IsoScene = new IsoScene();

                        scene.hostContainer = this;

                        scene.addChild(box);

                        scene.render();

                }

        }

}

生成的是这个

 

   
![](http://dl.iteye.com/upload/attachment/353803/900fcf81-c0dd-36c6-99c6-11ef52b9635f.jpg)  
 

google的图都被墙了 鄙人钦佩至极···

先添加的左边 长条 然后最右边的板砖 最后是中间的方块

如果加上这行代码 

scene.layoutEnabled = false;

那么 系统会按照添加顺序排序 

![](http://dl.iteye.com/upload/attachment/353809/e9bd58d8-aa3e-379b-a3cd-addd6bc061e8.png)  
 

如果去掉了上面那句 

![](http://dl.iteye.com/upload/attachment/353812/08247a22-bfb0-3ab1-8528-a260981901b6.png)  
 

所以最好让系统自己排序吧~

code是

```
var box0:IsoBox = new IsoBox();
box0.setSize(25, 25, 25);
box0.moveTo(200, 0, 0);
var box1:IsoBox = new IsoBox();
box1.width = 10;
box1.length = 25;
box1.height = 50;
box1.moveTo(230, -15, 20);
var box2:IsoBox = new IsoBox();
box2.setSize(10, 50, 5);
box2.moveTo(200, 30, 10);
var scene:IsoScene = new IsoScene();
scene.layoutEnabled = false;
scene.hostContainer = this;
scene.addChild(box1);
scene.addChild(box2);
scene.addChild(box0);
scene.render();
```

 

as3isolib 的最原始类型 有各种各样的样式属性可供设置

这些属性包括

1.渲染类型  确定原始类型按照哪种模式进行渲染   render style

  可供选择的有 1.阴影模式 2.固体模式 和 3.线框模式

2.face line alphas 表面线条的透明度 多边形边缘的透明度

  face line colors 表面线条的颜色 多边形边缘的颜色

  face line thicknesses 线条的粗细 多边形边缘的粗细

  face alphas 多边形表面的透明度

  face colors 多边形表面的颜色

默认的渲染类型是  RenderStyleType.SHADED （阴影模式） 这个模式的意思是 如果有一个面和另外的面有颜色重叠的话 颜色会有变化 比如加深什么的·····

RenderStyleType.SOLID则会把每个面都设置为#FFFFFF的颜色

RenderStyleType.WIREFRAME 的每个面都是透明的 不过依然可以接受鼠标点击事件

看下面这个例子 表面的透明度和颜色都被改变了.  正如你所看到的 因为每个面都设置了边框粗细. 

所以在后边的的面的边缘呈现出来了

![](http://dl.iteye.com/upload/attachment/353814/9b6b6bc0-0349-3c48-abc6-7890fcd33f4e.jpg)  
 

var box:IsoBox = new IsoBox();

     box.styleType = **RenderStyleType.SHADED;**

     box.faceColors = \[ 0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff ]

     box.faceAlphas = \[.5, .5, .5, .5, .5, .5];

     box.setSize(25, 30, 40);

     box.moveTo(200, 0, 0);

                        

var scene:IsoScene = new IsoScene();

     scene.hostContainer = this;

     scene.addChild(box);

     scene.render();

如果用RenderStyleType.SOLID 则不会改变颜色

code如下：

box.styleType = **RenderStyleType.SOLID;**

box.faceColors = \[0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff]

box.faceAlphas = \[.5, .5, .5, .5, .5, .5];

效果如下

![](http://dl.iteye.com/upload/attachment/353816/6b399266-7be0-37ca-8bde-cabf43dc0f6c.jpg)  
 

如果使用 RenderStyleType.WIREFRAME 来渲染  则会忽略表面的颜色和透明度

注意 阴影依然会渲染 因为阴影是场景渲染的 而不是原始二等角他本身~

code 如下：

box.styleType = **RenderStyleType.WIREFRAME;**

box.faceColors = \[0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff]

box.faceAlphas = \[.5, .5, .5, .5, .5, .5];

效果如下：

![](http://dl.iteye.com/upload/attachment/353824/9c532eae-6fb9-3a62-93fb-c2c493a21530.jpg)  
 

ohyeah~第三章完了 哈哈哈~