Example #1
0
 /**
  * Sets an actor property.
  *
  * @param property Property to set
  * @param newValue Value to use
  * @return True if the property is set successfully
  * @hide
  */
 @Override
 public final <T> boolean setValue(Property<T> property, T newValue, boolean dirty) {
   if (super.setValue(property, newValue, dirty)) {
     // This function is overridden to ensure the scene is re-rendered.
     if (mPresentation != null) {
       mPresentation.requestRender();
     }
     return true;
   }
   return false;
 }
Example #2
0
  /**
   * Realize this actor.
   *
   * @param actorPresentation Presentation used for realizing actor
   * @hide
   */
  public void realize(Presentation actorPresentation) {
    if (mPresentation == null) {
      mPresentation = actorPresentation.createActorNodePresentation(mNodeName);
      mPresentation.initialize(this);

      // There are dependencies between static properties, ex:
      // PROP_SRC_RECT depends on PROP_IMG_SRC In the end we have to use
      // applyAllProperties() to apply all properties with dependencies
      // which applyAllExistingValues doesn't consider it.
      applyAllProperties();
    }

    applyAllDirtyValues();
  }
Example #3
0
 /**
  * Un-realize this actor.
  *
  * @hide
  */
 public void unrealize() {
   if (mPresentation != null) {
     mPresentation.uninitialize();
     mPresentation = null;
   }
 }
Example #4
0
  /**
   * Applies a property to the node.
   *
   * @param property Property to apply
   * @param value Value to apply
   * @return True if the property was applied successfully
   * @hide
   */
  protected boolean applyValue(Property property, Object value) {
    // If the value is null, this is generally because the default property
    // value is null.  We take it to mean "do nothing".
    if (value != null) {
      if (property.sameInstance(PROP_POSITION)) {
        mPresentation.setPosition((Point) value);
      } else if (property.sameInstance(PROP_ROTATION)) {
        mPresentation.setRotation((Rotation) value);
      } else if (property.sameInstance(PROP_SCALE)) {
        mPresentation.setScale((Scale) value);
      } else if (property.sameInstance(PROP_VISIBLE)) {
        mPresentation.setVisible((Boolean) value);
      } else if (property.sameInstance(PROP_COLOR)) {
        mPresentation.setColor((Color) value);
      } else if (property.sameInstance(PROP_OPACITY)) {
        mPresentation.setOpacity((Integer) value);
      } else if (property.sameInstance(PROP_COLLISION_SHAPE)) {
        mPresentation.setCollisionShape((Integer) value);
      } else if (property.sameInstance(PROP_COLLISION_POSITION)) {
        mPresentation.setCollisionPosition((Point) value);
      } else if (property.sameInstance(PROP_COLLISION_ROTATION)) {
        mPresentation.setCollisionRotation((Rotation) value);
      } else if (property.sameInstance(PROP_COLLISION_SCALE)) {
        mPresentation.setCollisionScale((Scale) value);
      } else if (property.sameInstance(PROP_COLLISION_VISIBLE)) {
        mPresentation.setCollisionVisible((Boolean) value);
      } else {
        return false;
      }
    }

    return true;
  }