void TMXOrthoVertexZNew::repositionSprite(float dt) { // tile height is 101x81 // map size: 12x12 auto p = _tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); _tamara->setPositionZ( -( (p.y+81) /81) ); }
SpriteFrame* Sprite::getSpriteFrame() const { return SpriteFrame::createWithTexture(_texture, CC_RECT_POINTS_TO_PIXELS(_rect), _rectRotated, CC_POINT_POINTS_TO_PIXELS(_unflippedOffsetPositionFromCenter), CC_SIZE_POINTS_TO_PIXELS(_contentSize)); }
void TMXIsoVertexZNew::repositionSprite(float dt) { // tile height is 64x32 // map size: 30x30 auto p = _tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); float newZ = -(p.y+32) /16; _tamara->setPositionZ( newZ ); }
void HelloWorld::repositionSprite(float dt) { Vec2 p = m_tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); Node* map = getChildByTag(1); int newZ = 4 - (p.y / 48); newZ = MAX(newZ, 0); map->reorderChild(m_tamara, newZ); }
void HelloWorld::repositionSprite(float dt) { auto p = m_testSp->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); auto map = getChildByTag(1); int newZ = 4 - (p.y / 48); newZ = std::max(newZ,0); map->reorderChild(m_testSp, newZ); }
SpriteFrame* MGRBlurSprite::getSpriteFrame() const { if(nullptr != this->_spriteFrame) { return this->_spriteFrame; } return SpriteFrame::createWithTexture(_texture, CC_RECT_POINTS_TO_PIXELS(_rect), _rectRotated, CC_POINT_POINTS_TO_PIXELS(_unflippedOffsetPositionFromCenter), CC_SIZE_POINTS_TO_PIXELS(_contentSize)); }
void Scale9Sprite::createSlicedSprites() { //todo create sliced sprite if (_scale9Enabled) { Texture2D *tex = _scale9Image ? _scale9Image->getTexture() : nullptr; if (tex == nullptr) { return; } if (_renderingType == RenderingType::SIMPLE) { this->configureSimpleModeRendering(); } auto capInsets = CC_RECT_POINTS_TO_PIXELS(_capInsetsInternal); auto textureRect = CC_RECT_POINTS_TO_PIXELS(_spriteRect); auto spriteRectSize = _spriteRect.size; auto originalSize = CC_SIZE_POINTS_TO_PIXELS(_originalSize); auto offset = CC_POINT_POINTS_TO_PIXELS(_offset); Vec4 offsets; offsets.x = offset.x + (originalSize.width - textureRect.size.width) / 2; offsets.w = offset.y + (originalSize.height - textureRect.size.height) / 2; offsets.z = originalSize.width - textureRect.size.width - offsets.x; offsets.y = originalSize.height - textureRect.size.height - offsets.w; //handle .9.png if (_isPatch9) { originalSize = Size(originalSize.width - 2, originalSize.height-2); } if(capInsets.equals(Rect::ZERO)) { capInsets = Rect(originalSize.width/3, originalSize.height/3, originalSize.width/3, originalSize.height/3); } auto uv = this->calculateUV(tex, capInsets, originalSize, offsets); auto vertices = this->calculateVertices(capInsets, originalSize, offsets); auto triangles = this->calculateTriangles(uv, vertices); _scale9Image->getPolygonInfo().setTriangles(triangles); } }
void TMXIsoZorderNew::repositionSprite(float dt) { auto p = _tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); auto map = getChildByTag(kTagTileMap); // there are only 4 layers. (grass and 3 trees layers) // if tamara < 48, z=4 // if tamara < 96, z=3 // if tamara < 144,z=2 int newZ = 4 - (p.y / 48); newZ = std::max(newZ,0); map->reorderChild(_tamara, newZ); }
void TMXOrthoZorderNew::repositionSprite(float dt) { auto p = _tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); auto map = getChildByTag(kTagTileMap); // there are only 4 layers. (grass and 3 trees layers) // if tamara < 81, z=4 // if tamara < 162, z=3 // if tamara < 243,z=2 // -10: customization for this particular sample int newZ = 4 - ( (p.y-10) / 81); newZ = std::max(newZ,0); map->reorderChild(_tamara, newZ); }
void SpriteFrame::setOffset(const Vec2& offsets) { _offset = offsets; _offsetInPixels = CC_POINT_POINTS_TO_PIXELS( _offset ); }
void CCSpriteFrame::setOffset(const CCPoint& offsets) { m_obOffset = offsets; m_obOffsetInPixels = CC_POINT_POINTS_TO_PIXELS( m_obOffset ); }