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


C++ GraphicObject::setRect方法代码示例

本文整理汇总了C++中GraphicObject::setRect方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicObject::setRect方法的具体用法?C++ GraphicObject::setRect怎么用?C++ GraphicObject::setRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicObject的用法示例。


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

示例1: init

bool App::init() {
    _scene = new Scene;

    _core = new Core;
    _core->initialize();

    connect(_core, SIGNAL(exit()), this, SLOT(quit()));


    // delete later
    _background = new GraphicObject;

    _background->setSurface(_core->getSurface("background.png"));
    SDL_Rect backRect = {0, 0, 1500, 843};
    _background->setRect(backRect);
    qsrand(time(NULL));
    _scene->setBack(_background);

    connect(_core->getEH(), SIGNAL(eventMsg(SDL_Event*)),
            this, SLOT(event(SDL_Event*)));

    // creating state ------------------------------
    Battle *battle = new Battle;
    Scene *batScene = new Scene;
    battle->setScene(_scene);


    loadUnits(battle);

    // gates
    SDL_Rect gateRect;
    gateRect.x = 0;
    gateRect.y = 0;
    gateRect.w = 30;
    gateRect.h = 30;
    CombinedAnimation gateAnLeft;
    gateAnLeft.setSurface(_core->getSurface("leftgate.png"));
    gateAnLeft.setFrameLines(2);
    gateAnLeft.setMaxFrames(7);
    gateAnLeft.setFrames(0, 4);
    gateAnLeft.setFrames(1, 7);
    CombinedAnimation gateAnRight;
    gateAnRight.setSurface(_core->getSurface("rightgate.png"));
    gateAnRight.setFrameLines(2);
    gateAnRight.setMaxFrames(7);
    gateAnRight.setFrames(0, 4);
    gateAnRight.setFrames(1, 7);
    gateAnRight.flipHorizontal();
    DamageableItem g1(1000, Position(310, SPAWN_LINE),Size(100, 90), 9);
    DamageableItem g2(1000, Position(1200, SPAWN_LINE),Size(100, 90), 19);

    // left castle
    SDL_Rect wallRect = {0, 0, 297, 230};
    Animation leftWallAn;
    leftWallAn.setSurface(_core->getSurface("castle.png"));
    leftWallAn.setFrames(1);
    leftWallAn.setRect(wallRect);
    leftWallAn.flipHorizontal();
    AreaItem leftWallItem(147, SPAWN_LINE, 220, 195);
    QSharedPointer<Castle> lCastle = QSharedPointer<Castle>(new Castle(leftWallItem, g1, leftWallAn, gateAnLeft, Position(100, SPAWN_LINE), 5, 1, 1500));
    battle->setLeftCastle(lCastle);

    // right castle

    Animation wallAn;
    wallAn.setSurface(_core->getSurface("castle.png"));
    wallAn.setFrames(1);
    wallAn.setRect(wallRect);
    AreaItem wallItem(1365, SPAWN_LINE, 220, 195);
    QSharedPointer<Castle> rCastle = QSharedPointer<Castle>(new Castle(wallItem, g2, wallAn, gateAnRight, Position(1400, SPAWN_LINE), 5, 0, 1500));
    battle->setRightCastle(rCastle);

    // Player stats
    QList<SDL_Surface*> iconSurfs;
    iconSurfs << _core->getSurface("warrior_icon.png");
    iconSurfs << _core->getSurface("ranger_icon.png");
    iconSurfs << _core->getSurface("rangerwall_icon.png");
    iconSurfs << _core->getSurface("knight_icon.png");
    iconSurfs << _core->getSurface("evilwarrior_icon.png");
    iconSurfs << _core->getSurface("evilranger_icon.png");
    iconSurfs << _core->getSurface("evilrangerwall_icon.png");
    iconSurfs << _core->getSurface("evilknight_icon.png");
    PlayerStats *stats = new PlayerStats(iconSurfs);

    battle->setPlayerStats(stats);

    // barrier floor
    QSharedPointer<AreaItem> floor
            = QSharedPointer<AreaItem>(new AreaItem(450, SPAWN_LINE + 700,
                                                    3000, 699, 0, true, true));
    battle->setFloor(floor);

    // win sets
    GraphicObject *right = new GraphicObject();
    GraphicObject *left = new GraphicObject();
    GraphicObject *draw = new GraphicObject();
    right->setSurface(_core->getSurface("rightwin.png"));
    left->setSurface(_core->getSurface("leftwin.png"));
    draw->setSurface(_core->getSurface("draw.png"));

//.........这里部分代码省略.........
开发者ID:BrainDestroyer,项目名称:hw,代码行数:101,代码来源:app.cpp


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