Example #1
0
 public void setContentSize(float w, float h) {
   if (!(contentSize_.width == w && contentSize_.height == h)) {
     contentSize_.set(w, h); // = CGSize.make(size.width, size.height);
     anchorPointInPixels_.set(
         contentSize_.width * anchorPoint_.x, contentSize_.height * anchorPoint_.y);
     isTransformDirty_ = isInverseDirty_ = true;
     if (ccConfig.CC_NODE_TRANSFORM_USING_AFFINE_MATRIX) {
       isTransformGLDirty_ = true;
     }
   }
 }
Example #2
0
  /** initializes a TMX Tiled Map with a TMX file */
  protected CCTMXTiledMap(String tmxFile) {
    super();
    if (tmxFile == null) {
      ccMacros.CCLOG(LOG_TAG, "TMXTiledMap: tmx file should not bi nil");
      return;
    }

    setContentSize(CGSize.zero());

    CCTMXMapInfo mapInfo = CCTMXMapInfo.formatWithTMXFile(tmxFile);

    assert (mapInfo.tilesets.size() != 0)
        : "TMXTiledMap: Map not found. Please check the filename.";

    mapSize_ = mapInfo.mapSize;
    tileSize_ = mapInfo.tileSize;
    mapOrientation_ = mapInfo.orientation;
    objectGroups = mapInfo.objectGroups;
    properties_ = mapInfo.properties;
    tileProperties_ = mapInfo.tileProperties;

    int idx = 0;
    for (CCTMXLayerInfo layerInfo : mapInfo.layers) {

      if (layerInfo.visible) {
        CCTMXLayer child = parseLayer(layerInfo, mapInfo);
        addChild(child, idx, idx);

        // update content size with the max size
        CGSize childSize = child.getContentSize();
        CGSize currentSize = getContentSize();
        currentSize.width =
            (currentSize.width > childSize.width ? currentSize.width : childSize.width);
        currentSize.height =
            (currentSize.height > childSize.height ? currentSize.height : childSize.height);
        setContentSize(currentSize);

        idx++;
      }
    }
  }
Example #3
0
  /** initializes the node */
  protected CCNode() {
    transformGL_ = new float[16];

    isRunning_ = false;

    rotation_ = 0.0f;
    scaleX_ = scaleY_ = 1.0f;
    skewX_ = skewY_ = 0.0f;
    position_ = CGPoint.ccp(0, 0);

    transform_ = CGAffineTransform.identity();
    inverse_ = CGAffineTransform.identity();

    // "whole screen" objects. like Scenes and Layers, should set relativeAnchorPoint to false
    isRelativeAnchorPoint_ = true;

    anchorPointInPixels_ = CGPoint.ccp(0, 0);
    anchorPoint_ = CGPoint.ccp(0, 0);
    contentSize_ = CGSize.zero();

    isTransformDirty_ = isInverseDirty_ = true;

    if (ccConfig.CC_NODE_TRANSFORM_USING_AFFINE_MATRIX) {
      isTransformGLDirty_ = true;
    }

    zOrder_ = 0;
    vertexZ_ = 0;
    grid_ = null;
    visible_ = true;
    tag_ = kCCNodeTagInvalid;

    // lazy alloc
    camera_ = null;

    // children (lazy allocs)
    children_ = null;

    // userData is always inited as nil
    userData = null;
  }
Example #4
0
 public CGSize getContentSize() {
   return CGSize.make(contentSize_.width, contentSize_.height);
 }