从Processing迁移到Flash CS5,我该如何开始?
我已经使用Processing大约两年了,我真的很喜欢它。不过,我觉得 Flash 对于编写游戏更有用,因为它更通用、更灵活。我开始觉得我不知道自己在做什么,而且我真的不明白任何概念,比如电影剪辑和舞台等等。在处理过程中,为了制作一个球,我可能会这样做:
Ball[] ballArray = new Ball[ 0 ]; //Array to store each ball in
无效设置()
{
大小( 400, 400 );
无效
绘制()
{
背景(255);
for( int i = 0; i < ballArray.length; i++ )
{
ballArray[ i ].display(); //每个时间步运行每个球的显示代码
}
}
球类
{
PV矢量位置; //存储球位置的向量
球 ( int x, int y )
{
位置 = new PVector( x, y );
ballArray = ( Ball[] ) 追加 ( ballArray, this ); //将这个球添加到数组中
}
无效显示()
{
填充(0);
椭圆(位置.x,位置.y); //在它的位置显示这个球
}
}
无效 mousePressed()
{
新球(鼠标X,鼠标Y); //在鼠标位置创建一个新球
}
这将让我可以在任何我喜欢的地方创建任意数量的实例。 我对如何在 Flash 中制作类似的小程序一无所知。 我尝试在单独的 .as 文件中创建一个“ball”类,但它给了我一个关于参数太多的错误。我也不知道如何直接在屏幕上绘制形状。
有人可以在 Flash 中制作出类似的东西,这样我就可以开始了吗? 如果我能得到一些针对闪存菜鸟的推荐读物,那就太棒了, 或者开发人员从 Java 转向 Flash。
I've been using Processing for around two years now, and I really like it. However, I feel like Flash is a bit more useful for coding games, as it's more universal and flexible. I'm starting to feel like I have no idea what I'm doing, and I really don't get any of the concepts like movie clips and the stage and so forth. In Processing, to make, say, a ball, I might make this:
Ball[] ballArray = new Ball[ 0 ]; //Array to store each ball in
void setup()
{
size( 400, 400 );
}
void draw()
{
background( 255 );
for( int i = 0; i < ballArray.length; i++ )
{
ballArray[ i ].display(); //Run each ball's display code every time step
}
}
class Ball
{
PVector location; //Vector to store this ball's location in
Ball( int x, int y )
{
location = new PVector( x, y );
ballArray = ( Ball[] ) append( ballArray, this ); //Add this ball to the array
}
void display()
{
fill( 0 );
ellipse( location.x, location.y ); //Display this ball at its location
}
}
void mousePressed()
{
new Ball( mouseX, mouseY ); //Create a new ball at the mouse location
}
And that would let me create as many instances as I like, anywhere I like.
I haven't the faintest clue how to make a comparable applet in Flash.
I've tried making a 'ball' class in a separate .as file, but it gives me an error about too many arguments. I also don't know how to draw a shape directly to the screen.
Can somebody whip up an equivalent of this in Flash so I have something to start from?
It'd also be fantastic if I could get some recommended reading for total flash noobs,
or developers moving from Java to Flash.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是一个简单的 Flash 影片/应用程序,它创建
Ball
的新实例,并在您在舞台上单击鼠标时将其添加到舞台。此外,每次创建Ball
的新实例时,都会将其附加到名为_balls
的Ball
对象数组中。Main.as(文档类):
Ball.as:
我建议阅读“Roger Braunstein 的 ActionScript 3.0 Bible”一书,了解 Flash(以及 Flex)“菜鸟”。此外,即使您熟悉 ActionScript 3,它也可以作为一本很好的参考书。
此外,一旦您开始很好地掌握 ActionScript 3,您可能会考虑进入设计模式领域。将设计模式简化为一个简单的句子,可能是它们是“应对软件设计和开发中不断变化的工具”。我建议阅读“O'Reilly,William Sanders 和 Chandima Cumaranatunge 所著的 ActionScript 3.0 设计模式”。
The following is a simple flash movie/app that creates a new instance of
Ball
and adds it to the stage when and where you click the mouse on the stage. Also upon each creation of a new instance ofBall
, its appended to an array ofBall
objects called_balls
.Main.as(document class):
Ball.as:
I recommend reading the "ActionScript 3.0 Bible by Roger Braunstein" book for flash(as well as flex) "noobs". Also, even if you are experienced with ActionScript 3, it serves as a good reference book.
Also once you start to get a good grip on ActionScript 3, you may want to consider entering the realm of design patterns. To simplfy design patterns into a simple sentence it would probably be that they're "tools for coping with constant change in software design and development". I recommend reading "O'Reilly, ActionScript 3.0 Design Patterns by William Sanders & Chandima Cumaranatunge".
查看 Colin Mook 的 Lost Actionscript Week End 视频教程,这将使您对 Actionscript 有一个很好的概述,并有足够的了解将您的处理知识应用到 Flash。请记住,在Processing 中,许多方法对您来说是隐藏的,您可能需要编写更多代码才能使Processing 概念适应AS3。
http://tv.adobe.com/show/colin-moocks-丢失动作脚本周末/
Check Colin Mook's Lost Actionscript Week End video tutorial , this will give you a good overview of Actionscript and enough understanding to apply your Processing knowledge to Flash. Bear in mind that in Processing a lot of the methods are hidden from you and you may have to write a lot more code in order to adapt Processing concepts to AS3.
http://tv.adobe.com/show/colin-moocks-lost-actionscript-weekend/