company logo
advertisement for deep fried Twinkies


我的 ActionScript 3.0 game programming university 学习笔记


 

原网址:http://flash.9ria.com/thread-4734-1-1.html

先介绍下文章内容,有个整体的印象!
1. 使用flash和ActionScript3.0
2. ActionScript 游戏元素
/*下面是一些游戏实例*/
3. Basic Game Framework: A Matching Game
4. Brain Games: Memory and Deduction
5. Game Animation: Shooting and Bouncing Games
6. Picture Puzzles: Sliding and Jigsaw
7. Direction and Movement: Space Rocks
8. Casual Games: Match Three
9. Word Games: Hangman and Word Search
10. Questions and Answers: Trivia and Quiz Games
11. Action Games: Platform Games
12. Game Worlds: Driving and Exploration Game
Index

2. ActionScript 游戏元素

书中应该会介绍几乎每个游戏编程都会用到的东东,我想是这样的啊!

(1) 是创建视觉对象

大概包括使用影片剪辑,就是MC啦~, 制作按钮, 画形状(shapes), 写文本,创建链接文本, 设置Sprite组, 设置Sprite深度

当你在库中创建了MC,那么你想把它放到场景中来, 那么会有两种方法实现

第一个方法是拖动mc到场景中并且在属性面板中给他个名字, 比如说命名为myClipInstance, 然后你就可以通过MC的属性控制它了,比如说控制他的坐标位置,我们可以这样写:

myClipInstance.x = 300;
myClipInstance.y = 200;

第二种方法就是纯粹的AS代码了, 但首先你必须设置一下库中MC的linkage properties, as3不能使用表示符了, 库中的mc都会绑定到指定的类中, 我们在class那块填写类名 Mascot, 然后我们可以在场景中使用as程序创建副本,并使用addChild函数使其加到显示列表中,让他显示出来!代码如下:

var myMovieClip:Mascot = new Mascot();
addChild(myMovieClip);

因为我们没有设定其他的属性,所以他将会出现在场景中的坐标(0,0)位置, 我们可以通过x,y属性设定它的坐标, 并且也可以设定它的旋转角度

var myMovieClip:Mascot = new Mascot();
myMovieClip.x = 275;
myMovieClip.y = 150;
myMovieClip.rotation = 10;
addChild(myMovieClip);

尽管我们为了一个MC作了大量的工作,但是AS会非常容易的创建这个MC的很多副本,下面的代码将创建Mascot的10个副本, 并且每隔50像素横向排列着, 同时也把MC缩小了50%

for(var i=0;i<10;i++) {
var mascot:Mascot = new Mascot();
mascot.x = 50*i+50;
mascot.y = 300;
mascot.scaleX = .5;
mascot.scaleY = .5;
addChild(mascot);
}

使用影片剪辑的知识在这本书里就到此为止了! 松口气, 哈哈, 写笔记真爽, 至少比看的印象深刻10倍噢!