Beispiel #1
0
InfoBar::InfoBar( QWidget *parent )
	: QWidget( parent )
{
	setBackgroundColor();
	createLayout();
	createIcon();
	createLabel();
	createCloseButton();
}
Beispiel #2
0
Highlighter::Highlighter(const ElementArea& area)
  : QWidget()
{
  setWindowTitle("Highlighter");
  setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
  setWindowOpacity(0.5);

  setArea(area);
  createCloseButton();
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{

    loader.SetFilePath(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename("YellowBall.json"));
    netPotLoader.SetFilePath(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename("netpot.json"));

    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }

    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();



    ///////////////////////////////////////////////////////////nazib edit//////////////////////////////////////////////////////
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 1, true);
    //bool b = this->isTouchEnabled();
    //this->setTouchEnabled(true);
    // b = this->isTouchEnabled();

    //========================================[create yellow ball sprite]================================
    CCSprite* pSpriteYellowBall;
    pSpriteYellowBall = CCSprite::create("YellowBall.png");
    pSpriteYellowBall->setPosition(ccp(100,300));
    this->addChild(pSpriteYellowBall,1);
    //====================================================================================================






    //========================================[Create world]==============================================
    b2Vec2 gravity = b2Vec2(0.0f,-9.8f);
    pworld = new b2World(gravity);
    //====================================================================================================


    //========================================[Create YellowBall Body]====================================

    // Create ball body and shape
    b2BodyDef yellowBallBodyDef;
    yellowBallBodyDef.type = b2_dynamicBody;
    yellowBallBodyDef.position.Set(100/PTM_RATIO, 300/PTM_RATIO);
    yellowBallBodyDef.userData = pSpriteYellowBall;
    pbodyYellowBall= pworld->CreateBody(&yellowBallBodyDef);

    //b2CircleShape circle;
    //circle.m_radius = 26.0/PTM_RATIO;

    b2FixtureDef ballShapeDef;
    //ballShapeDef.shape = &circle;
    ballShapeDef.density = 1.0f;
    ballShapeDef.friction = 0.2f;
    ballShapeDef.restitution = 0.8f;
    //pbodyYellowBall->CreateFixture(&ballShapeDef);
    loader.attachFixture(pbodyYellowBall, "Name", ballShapeDef, 50/PTM_RATIO);

    //====================================================================================================



    //////////////////////////////////////////////////////////////////////////

    //create netpot sprite
    createNetPot();


    //////////////////////////////////////////////////////////////////////////



    createGroundWall();
    createLeftWall();
    createRightWall();
    createTopWall();

    createCloseButton(origin, visibleSize);


    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label

    pLabel = CCLabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE);

    // position the label on the center of the screen
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(pLabel, 1);

    // add "HelloWorld" splash screen"
    /*CCSprite* */
    pSprite = CCSprite::create("BackGround.png");
    pNextSprite = CCSprite::create("BackGround.png");

    // position the sprite on the center of the screen
    // pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    //this->addChild(pSprite, 0);

    //=============================================[Parallax Node]=========================================================



    pBackgroundNode = CCParallaxNodeExtras::node();
    this->addChild(pBackgroundNode, -1);

    CCPoint bgSpeed = ccp(0.05, 0.05);

    pBackgroundNode->addChild(pSprite, 0, bgSpeed, ccp(0,visibleSize.height/2) );
    pBackgroundNode->addChild(pNextSprite, 0, bgSpeed, ccp( pSprite->getContentSize().width,visibleSize.height/2));


    //====================================================================================================================

    this->schedule(schedule_selector(HelloWorld::tick),1/60);

    // CCDirector::sharedDirector() -> getTouchDispatcher() -> addStandardDelegate( this, 0 );

    return true;
}