当前位置: 首页>>代码示例>>C++>>正文


C++ CC_POINT_PIXELS_TO_POINTS函数代码示例

本文整理汇总了C++中CC_POINT_PIXELS_TO_POINTS函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_POINT_PIXELS_TO_POINTS函数的具体用法?C++ CC_POINT_PIXELS_TO_POINTS怎么用?C++ CC_POINT_PIXELS_TO_POINTS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CC_POINT_PIXELS_TO_POINTS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: log

bool HelloWorld::init()
{
    if ( !LayerColor::initWithColor(Color4B(255, 255, 255, 255) ))
    {
        return false;
    }

	auto map = TMXTiledMap::create("TileMaps/iso-test-zorder.tmx");
	this->addChild(map, 0, 1);

	Size s = map->getContentSize();
	log("ContentSize : %f, %f", s.width, s.height);
	map->setPosition(Vec2(-s.width/2 , 0));

	m_tamara = Sprite::create("Images/grossinis_sister1.png");
	map->addChild(m_tamara, map->getChildren().size());
	int mapWidth = map->getMapSize().width * map->getTileSize().width;
	m_tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2(mapWidth / 2, 0)));
	m_tamara->setAnchorPoint(Vec2(0.5f, 0));

	auto move = MoveBy::create(10, Vec2(300, 250));
	auto back = move->reverse();
	auto seq = Sequence::create(move, back, nullptr);
	m_tamara->runAction(RepeatForever::create(seq));

	schedule(schedule_selector(HelloWorld::repositionSprite));

    return true;
}
开发者ID:kimsibaek,项目名称:cocos2d-x-work,代码行数:29,代码来源:HelloWorldScene.cpp

示例2: log

void TileMap::setPlayerPosition(Point position, Player player) {
	std::string pathAhead = this->metaLayerChecker(position);
	if (pathAhead == "Edge") {
		log("Stopped by the Edge of the map");
	}
	else if ((pathAhead == "Solid") && (player.getPower().getSolid() == false)) {
		log("Stopped by Solid");
	}
	else if ((pathAhead == "Water") && (player.getPower().getWater()==false)) {
		log("Stopped by Water");
	}
	else if ((pathAhead == "Ice") && (player.getPower().getIce() == false)) {
		log("Stopped by Ice");
	}
	else if ((pathAhead == "Fire") && (player.getPower().getFire() == false)) {
		log("Stopped by Fire");
	}
	else if (pathAhead == "segundoNivel"){
		log("Nivel1 Completado");
		Size visibleSize = Director::getInstance()->getVisibleSize();
		auto label1 = LabelTTF::create("Nivel1 Completado", "Book Antigua", 40);
		label1->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));
		this->addChild(label1, 1);

		auto newScene = SegundoNivel::createScene();
		Director::getInstance()->replaceScene(CCTransitionFade::create(7.5f, newScene));
	}
	else if (pathAhead == "tercerNivel"){
		log("Nivel2 Completado");
		Size visibleSize = Director::getInstance()->getVisibleSize();
		auto label1 = LabelTTF::create("Nivel2 Completado", "Book Antigua", 40);
		label1->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));
		this->addChild(label1, 1);

		auto newScene = TercerNivel::createScene();
		Director::getInstance()->replaceScene(CCTransitionFade::create(7.5f, newScene));

	}else if (pathAhead == "finishGame"){
		log("Nivel3 Completado");
		Size visibleSize = Director::getInstance()->getVisibleSize();
		auto label1 = LabelTTF::create("Nivel3 Completado", "Book Antigua", 40);
		label1->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));
		this->addChild(label1, 1);

		auto newScene = MenuInicio::createScene();
		Director::getInstance()->replaceScene(CCTransitionFade::create(7.5f, newScene));
	}
	else{
		player.setPosition(position);
		Point View = setPointOfViewCenter(position);
		tileMap->setPosition(CC_POINT_PIXELS_TO_POINTS(View));
		this->loadPowers(position, player, pathAhead);
	}
}
开发者ID:Magnus1Proyect,项目名称:Magnus,代码行数:54,代码来源:TileMap.cpp

示例3: setScaleX

bool CCTMXLayer::initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo)
{    
    // XXX: is 35% a good estimate ?
    CCSize size = layerInfo->m_tLayerSize;
    float totalNumberOfTiles = size.width * size.height;
    float capacity = totalNumberOfTiles * 0.35f + 1; // 35 percent is occupied ?

    CCTexture2D *texture = NULL;
    if( tilesetInfo )
    {
        texture = CCTextureCache::sharedTextureCache()->addImage(tilesetInfo->m_sSourceImage.c_str());
    }

    if (CCSpriteBatchNode::initWithTexture(texture, (unsigned int)capacity))
    {
		if(tilesetInfo->m_IsNeedFlipX)
		{
			layerInfo->m_tOffset.x = layerInfo->m_tLayerSize.width;
			setScaleX(-1);
		}
        // layerInfo
        m_sLayerName = layerInfo->m_sName;
        m_tLayerSize = size;
        m_pTiles = layerInfo->m_pTiles;
        m_uMinGID = layerInfo->m_uMinGID;
        m_uMaxGID = layerInfo->m_uMaxGID;
        m_cOpacity = layerInfo->m_cOpacity;
        setProperties(CCDictionary::createWithDictionary(layerInfo->getProperties()));
        m_fContentScaleFactor = CCDirector::sharedDirector()->getContentScaleFactor(); 

        // tilesetInfo
        m_pTileSet = tilesetInfo;
        CC_SAFE_RETAIN(m_pTileSet);

        // mapInfo
        m_tMapTileSize = mapInfo->getTileSize();
        m_uLayerOrientation = mapInfo->getOrientation();

        // offset (after layer orientation is set);
        CCPoint offset = this->calculateLayerOffset(layerInfo->m_tOffset);
        this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));

        m_pAtlasIndexArray = ccCArrayNew((unsigned int)totalNumberOfTiles);

        this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(CCSizeMake(m_tLayerSize.width * m_tMapTileSize.width, m_tLayerSize.height * m_tMapTileSize.height)));

        m_bUseAutomaticVertexZ = false;
        m_nVertexZvalue = 0;
        
        return true;
    }
    return false;
}
开发者ID:hick1213,项目名称:cocos2dx-2.2-dds-texture-support,代码行数:53,代码来源:CCTMXLayer.cpp

示例4: setProperties

bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{    
    // FIXME:: is 35% a good estimate ?
    Size size = layerInfo->_layerSize;
    float totalNumberOfTiles = size.width * size.height;
    float capacity = totalNumberOfTiles * 0.35f + 1; // 35 percent is occupied ?

    Texture2D *texture = nullptr;
    if( tilesetInfo )
    {
        texture = Director::getInstance()->getTextureCache()->addImage(tilesetInfo->_sourceImage);
    }

    if (nullptr == texture)
        return false;

    if (SpriteBatchNode::initWithTexture(texture, static_cast<ssize_t>(capacity)))
    {
        // layerInfo
        _layerName = layerInfo->_name;
        _layerSize = size;
        _tiles = layerInfo->_tiles;
        _opacity = layerInfo->_opacity;
        setProperties(layerInfo->getProperties());
        _contentScaleFactor = Director::getInstance()->getContentScaleFactor(); 

        // tilesetInfo
        _tileSet = tilesetInfo;
        CC_SAFE_RETAIN(_tileSet);

        // mapInfo
        _mapTileSize = mapInfo->getTileSize();
        _layerOrientation = mapInfo->getOrientation();
        _staggerAxis = mapInfo->getStaggerAxis();
        _staggerIndex = mapInfo->getStaggerIndex();
        _hexSideLength = mapInfo->getHexSideLength();

        // offset (after layer orientation is set);
        Vec2 offset = this->calculateLayerOffset(layerInfo->_offset);
        this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));

        _atlasIndexArray = ccCArrayNew(totalNumberOfTiles);

        this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height)));

        _useAutomaticVertexZ = false;
        _vertexZvalue = 0;
        
        return true;
    }
    return false;
}
开发者ID:krzysztof-jusiak,项目名称:pi,代码行数:52,代码来源:CCTMXLayer.cpp

示例5: CC_RECT_PIXELS_TO_POINTS

bool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
{
    _texture = NULL;
    _textureFilename = filename;
    _rectInPixels = rect;
    _rect = CC_RECT_PIXELS_TO_POINTS( rect );
    _offsetInPixels = offset;
    _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );
    _originalSizeInPixels = originalSize;
    _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels );
    _rotated = rotated;

    return true;
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:14,代码来源:CCSpriteFrame.cpp

示例6: CC_RECT_PIXELS_TO_POINTS

bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
{
    _texture = nullptr;
    _textureFilename = filename;
    _rectInPixels = rect;
    _rect = CC_RECT_PIXELS_TO_POINTS( rect );
    _offsetInPixels = offset;
    _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );
    _originalSizeInPixels = originalSize;
    _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels );
    _rotated = rotated;

    return true;
}
开发者ID:skatpgusskat,项目名称:December,代码行数:14,代码来源:CCSpriteFrame.cpp

示例7: CC_RECT_PIXELS_TO_POINTS

bool CCSpriteFrame::initWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize)
{
    m_pobTexture = NULL;
    m_strTextureFilename = filename;
    m_obRectInPixels = rect;
    m_obRect = CC_RECT_PIXELS_TO_POINTS( rect );
    m_obOffsetInPixels = offset;
    m_obOffset = CC_POINT_PIXELS_TO_POINTS( m_obOffsetInPixels );
    m_obOriginalSizeInPixels = originalSize;
    m_obOriginalSize = CC_SIZE_PIXELS_TO_POINTS( m_obOriginalSizeInPixels );
    m_bRotated = rotated;

    return true;
}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:14,代码来源:CCSpriteFrame.cpp

示例8: CC_RECT_PIXELS_TO_POINTS

bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
{
    if (FileUtils::getInstance()->isFileExist(filename)) {
        _texture = nullptr;
        _textureFilename = filename;
        _rectInPixels = rect;
        _rect = CC_RECT_PIXELS_TO_POINTS( rect );
        _offsetInPixels = offset;
        _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );
        _originalSizeInPixels = originalSize;
        _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels );
        _rotated = rotated;
        _anchorPoint = Vec2(NAN, NAN);
        _centerRect = Rect(NAN, NAN, NAN, NAN);
        return true;
    }
    return false;
}
开发者ID:hugohuang1111,项目名称:Bird,代码行数:18,代码来源:CCSpriteFrame.cpp

示例9: switch

Point TMXLayer::getPositionAt(const Point& pos)
{
    Point ret = Point::ZERO;
    switch (_layerOrientation)
    {
    case TMXOrientationOrtho:
        ret = getPositionForOrthoAt(pos);
        break;
    case TMXOrientationIso:
        ret = getPositionForIsoAt(pos);
        break;
    case TMXOrientationHex:
        ret = getPositionForHexAt(pos);
        break;
    }
    ret = CC_POINT_PIXELS_TO_POINTS( ret );
    return ret;
}
开发者ID:lache,项目名称:anyang,代码行数:18,代码来源:CCTMXLayer.cpp

示例10: CC_SAFE_RETAIN

bool CCSpriteFrame::initWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize)
{
    m_pobTexture = pobTexture;

    if (pobTexture)
    {
        CC_SAFE_RETAIN(pobTexture);
    }

    m_obRectInPixels = rect;
    m_obRect = CC_RECT_PIXELS_TO_POINTS(rect);
    m_obOffsetInPixels = offset;
    m_obOffset = CC_POINT_PIXELS_TO_POINTS( m_obOffsetInPixels );
    m_obOriginalSizeInPixels = originalSize;
    m_obOriginalSize = CC_SIZE_PIXELS_TO_POINTS( m_obOriginalSizeInPixels );
    m_bRotated = rotated;

    return true;
}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:19,代码来源:CCSpriteFrame.cpp

示例11: CCASSERT

void GuanacasteScene::campFire()
{
    //carga el objeto del mapa
    auto Fogata = objetos->getObject("Fogata");
    CCASSERT(!Fogata.empty(), "Fogata object not found");
    //saco las coordenadas del objeto en el tilemap
    //se hace la suma debido al error en cocos2d
    float x = Fogata["x"].asFloat()+315;
    float y = Fogata["y"].asFloat()+28;
    //Crea el sprite y lo posiciona
    SFogata = Sprite::create("Animations/CampFire.png", Rect(0, 0,64,64));
    SFogata->setPosition(CC_POINT_PIXELS_TO_POINTS(Point(x,y)));
    //crea la animacion de la fogata
    auto animation = Animation::create();
    for ( int i = 0; i < 5; ++i )
    animation->addSpriteFrame(SpriteFrame::create("Animations/CampFire.png", Rect(i*64, 0,64,64)));
        animation->setDelayPerUnit( 0.1333f );
        auto repeatAnimation = RepeatForever::create( Animate::create(animation) );
        SFogata->runAction(repeatAnimation);
}
开发者ID:PadawanSofware,项目名称:Tiquicia,代码行数:20,代码来源:GuanacasteScene.cpp

示例12: setOpacity

bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{    

    if( tilesetInfo )
    {
        _texture = Director::getInstance()->getTextureCache()->addImage(tilesetInfo->_sourceImage);
        _texture->retain();
    }

    // layerInfo
    _layerName = layerInfo->_name;
    _layerSize = layerInfo->_layerSize;
    _tiles = layerInfo->_tiles;
    _quadsDirty = true;
    setOpacity( layerInfo->_opacity );
    setProperties(layerInfo->getProperties());

    // tilesetInfo
    _tileSet = tilesetInfo;
    CC_SAFE_RETAIN(_tileSet);

    // mapInfo
    _mapTileSize = mapInfo->getTileSize();
    _layerOrientation = mapInfo->getOrientation();

    // offset (after layer orientation is set);
    Vec2 offset = this->calculateLayerOffset(layerInfo->_offset);
    this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));

    this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height)));
    
    this->tileToNodeTransform();

    // shader, and other stuff
    setGLProgram(GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
    
    _useAutomaticVertexZ = false;
    _vertexZvalue = 0;

    return true;
}
开发者ID:keith1020,项目名称:cocos.github.io,代码行数:41,代码来源:CCFastTMXLayer.cpp

示例13: switch

Vec2 TMXLayer::getPositionAt(const Vec2& pos)
{
    Vec2 ret;
    switch (_layerOrientation)
    {
    case TMXOrientationOrtho:
        ret = getPositionForOrthoAt(pos);
        break;
    case TMXOrientationIso:
        ret = getPositionForIsoAt(pos);
        break;
    case TMXOrientationHex:
        ret = getPositionForHexAt(pos);
        break;
    case TMXOrientationStaggered:
        ret = getPositionForStaggeredAt(pos);
        break;
    }
    ret = CC_POINT_PIXELS_TO_POINTS( ret );
    return ret;
}
开发者ID:FenneX,项目名称:FenneXEmptyProject,代码行数:21,代码来源:CCTMXLayer.cpp

示例14: addChild

void HelloWorld::createMapAndAddChild()
{
    auto map = TMXTiledMap::create("test-zorder.tmx");
    addChild(map, 0, 1);
    
    auto s = map->getContentSize();
    map->setPosition(Point(-480,0));
    
    m_testSp = Sprite::create("grossinis_sister1.png");
    map->addChild(m_testSp, map->getChildren().size() );
    m_testSp->retain();
    int mapWidth = map->getMapSize().width * map->getTileSize().width;
    m_testSp->setPosition(CC_POINT_PIXELS_TO_POINTS(Point(mapWidth/2,0)));
    m_testSp->setAnchorPoint(Point(0.5f,0));
    
    auto move = MoveBy::create(10, Point(300,250));
    auto back = move->reverse();
    auto seq = Sequence::create(move, back,NULL);
    m_testSp->runAction( RepeatForever::create(seq) );
    
    schedule( schedule_selector(HelloWorld::repositionSprite) );
}
开发者ID:Ratel13,项目名称:book-code,代码行数:22,代码来源:HelloWorldScene.cpp

示例15: addChild

//------------------------------------------------------------------
//
// TMXIsoZorder
//
//------------------------------------------------------------------
TMXIsoZorder::TMXIsoZorder()
{
    auto map = TMXTiledMap::create("TileMaps/iso-test-zorder.tmx");
    addChild(map, 0, kTagTileMap);

    auto s = map->getContentSize();
    CCLOG("ContentSize: %f, %f", s.width,s.height);
    map->setPosition(Point(-s.width/2,0));
    
    _tamara = Sprite::create(s_pathSister1);
    map->addChild(_tamara, map->getChildren().size() );
    _tamara->retain();
    int mapWidth = map->getMapSize().width * map->getTileSize().width;
    _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Point( mapWidth/2,0)));
    _tamara->setAnchorPoint(Point(0.5f,0));

    
    auto move = MoveBy::create(10, Point(300,250));
    auto back = move->reverse();
    auto seq = Sequence::create(move, back,NULL);
    _tamara->runAction( RepeatForever::create(seq) );
    
    schedule( schedule_selector(TMXIsoZorder::repositionSprite) );
}
开发者ID:ioyouj,项目名称:Hello-LWF-Cocos2d-x,代码行数:29,代码来源:TileMapTest.cpp


注:本文中的CC_POINT_PIXELS_TO_POINTS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。