setPosition(Point(0,0)); addChild(layout); alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 ); alert->setColor(Color3B(159," name="description" />

Cocos2d-x Render-NewCulling

来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:26 点击:


.cpp

  layout->setBackGroundImageScale9Enabled(true);
        layout->setBackGroundImage("green_edit.png");
        
        layout->setPosition(Point(0,0));
        addChild(layout);
        
        
         alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 );
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Point(widgetSize.width / 2.0f,
                                 widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
        
        layout->addChild(alert);
        auto size = Director::getInstance()->getWinSize();

        /**************************************************************/
        
        auto sprite = Sprite::create("btn-about-normal-vertical.png");
        sprite->setRotation(5);
        sprite->setPosition(Point(size.width/2,size.height/3));
        sprite->setScale(2);
       layout-> addChild(sprite);
        
        auto sprite2 = Sprite::create("btn-about-normal-vertical.png");
        sprite2->setRotation(-85);
        sprite2->setPosition(Point(size.width/2,size.height * 2/3));
        sprite2->setScale(2);
         layout->addChild(sprite2);
        
        auto listener = EventListenerTouchOneByOne::create();
        listener->setSwallowTouches(true);
        
        listener->onTouchBegan = [=](Touch* touch, Event  *event) {
            auto pos = touch->getLocation();
            _lastPos = pos;
            
            
            return true;
            
            
        };
        
        listener->onTouchMoved = [=](Touch* touch, Event  *event) {
            auto pos = touch->getLocation();
            auto offset = pos - _lastPos;
            auto layerPos = getPosition();
            auto newPos = layerPos + offset;
            layout->setPosition(newPos);
            _lastPos = pos;
            
        };
        
        
        
        _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

        


    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • cocos2d-x学习笔记(19)--label 、label atlas
    • cocos2d-x学习笔记(23)--地图的使用3--CCTMXLayer
    • Cocos2d-x学习(一):HelloWorld
    • cocos2dx在xcode下开发,编译到android上(2)
    • cocos2d 设置屏幕默认方向
    • Cocos2d-x 2.0 之 Actions “三板斧” 之一
    • cocos2d-x学习笔记(22)--地图的使用2(TMX) --Z-Order、AnchorPoi
    • cocos2d-x学习笔记(18)--游戏打包(windows平台)
    • cocos2d-x学习笔记(16)--spritesheet(精灵表单)
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1