我是AS3的新手。我想创建一个在自己的构造函数类中定义的形状。
创建类时,它应该创建一个形状。(建设者)
我在以下代码中评论了我的需求:
ballShape类
public class ballShape {
public function ballShape() {
// define shape properties.
// create shape and put that in x = 0, y = 0
}
}
任何帮助都会很棒。
您可以在将您的班级扩展到Shape或Sprite时轻松地做到这一点
这是你的代码
public class ballShape extends Sprite {
public function ballShape() {
// define shape properties. The graphics object is already added to your Sprite, no need to manually addChild() this object.
graphics.beginFill(color, alpha); // you can begin a fill with this method, there are also methods to start a bitmap fill, gradient fill.
graphics.drawRect( x, y, width, height ); // draw a shape
graphics.endFill();
}
}
虽然Shape可以具有相同的功能来绘制形状和线条,但我选择Sprite是因为:
有关Graphics类的更多信息,请参考http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句