ape之AbstractItem

阅读 80

2023-01-08


看一组circleparticle类的继续关系:CircleParticle-->  AbstractParticle-->  AbstractItem 

AbstractItem是所有contraints和particles的基类。(The base class for all constraints and particles。)

顺便看一下AbstractParticle和AbstractContraint这两个类。因为依然是定义为抽象类,所以看一看神奇的大自然是怎么构造它的。


if (getQualifiedClassName(this) == "org.cove.ape::AbstractParticle") {
throw new ArgumentError("AbstractParticle can't be instantiated directly");
}



if (getQualifiedClassName(this) == "org.cove.ape::AbstractConstraint") {
throw new ArgumentError("AbstractConstraint can't be instantiated directly");
}



大自然用这个方法来防止是类被实例化。大自然真的好神奇呀~~ so sa la yi ya ~~


好鸟,下面看一下这个类的公有属性:

alwaysRepaint:Boolean

For performance, fixed Particles and SpringConstraints don't have their ​​ paint()​​​ method called in order to avoid unnecessary redrawing. A SpringConstraint is considered fixed if its two connecting Particles are fixed. Setting this property to​​true​​​ forces​​paint()​​​ to be called if this Particle or SpringConstraint​​fixed​​ property is true. If you are rotating a fixed Particle or SpringConstraint then you would set it's repaintFixed property to true. This property has no effect if a Particle or SpringConstraint is not fixed. 

出于性能的考虑,fixed particles和springconstraints没有paint()方法是为了避免不必要的(资源)开销。如果springconstraint的两个连接的粒子是固定的那么这个springconstraint 也被认为是固定的。设置这个属性为true则forces的paint()方法将被调用 如果这个particle和springconstraint的fixed属性设为true。如果你需要旋转一个fixed particle或spriteconstraint那么你需要把它的repaintFixed属性设为true。这个属性没有影响如果一个particle或springconstraint不是固定的。


sprite

Provides a Sprite to use as a container for drawing or adding children. When the sprite is requested for the first time it is automatically added to the global container in the APEngine class.


提供一个可以drawing或添加子children的一个容器。

(未完)




精彩评论(0)

0 0 举报