当前位置: 首页 > wzjs >正文

邢台做网站邮箱哪里有永久免费建站

邢台做网站邮箱,哪里有永久免费建站,最好的营销型网站案例,公司部门解散员工赔偿一:图元 advance函数: 在 Qt 框架里,QGraphicsItem 是用于在 QGraphicsScene 中绘制图形项的基类。advance(int phase) 是 QGraphicsItem 类的一个虚函数,其主要用途是让图形项在场景的动画或更新过程里完成特定的逻辑操作。 p…

一:图元

advance函数:

在 Qt 框架里,QGraphicsItem 是用于在 QGraphicsScene 中绘制图形项的基类。advance(int phase) 是 QGraphicsItem 类的一个虚函数,其主要用途是让图形项在场景的动画或更新过程里完成特定的逻辑操作。

phase 是一个整数参数,一般有两个阶段:

  • phase 为 0 时:代表预更新阶段,此阶段图形项能够为即将到来的更新做准备,像计算新的位置、状态等。
  • phase 为 1 时:代表主更新阶段,在这个阶段图形项可以依据预更新阶段的计算结果来更新自身的状态和外观。

#include "gameitem.h"GameItem::GameItem(QString filepath,bool isMove):QGraphicsItem()
{this->state=0;//图元读取一张图片才可以响应this->img.load(filepath);this->isMove=isMove;this->index=0;if( this->isMove==true){this->standPng=filepath;}}void GameItem::advance(int phase)
{if(this->state==1){this->img.load(this->standPng);}else {if(this->isMove){//替换QString path=QString("img/mario/marioR/%1.png").arg(index);this->img.load(path);//mapToScene告诉场景要移动多少this->setPos(mapToScene(3,0));this->index=(this->index+1)%21;//是否碰撞if(collidingItems().count()>0){this->img.load(this->standPng);this->setPos(mapToScene(-3,0));}}}}//让场景知道这个图元占用场景多少范围
QRectF GameItem::boundingRect() const
{return QRectF(0,0,img.width(),img.height());
}//让场景知道如何绘制这个图
void GameItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{painter->drawPixmap(0,0,img.width(),img.height(),img);}void GameItem::setState(int value)
{state = value;
}

二、场景

#include "gameview.h"GameView::GameView():QGraphicsView()
{this->setFixedSize(1333,364);this->setWindowTitle("Super Mario");this->setWindowIcon(QIcon("img/wm.png"));this->init();
}void GameView::init()
{//背景图片this->setBackgroundBrush(QBrush(QPixmap("img/background.png").scaled(1333,364)));//舞台this->gameScene=new QGraphicsScene;this->setScene(this->gameScene);//设置场景与视图坐标相同this->setSceneRect(0,0,this->width(),this->height());//隐藏滚动条this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//创建图元(演员)this->floor=new GameItem("img/ground.png",false);this->gameScene->addItem(this->floor);this->floor->setPos(0,291);//位置this->maro=new GameItem("img/mario/marioR/stand.png",true);this->gameScene->addItem(this->maro);this->maro->setPos(0,223);this->block=new GameItem("img/normalwall.png",false);this->gameScene->addItem(this->block);this->block->setPos(500,191);//计时器对象this->timer=new QTimer;this->timer->start(100);//启动计时器//计时相应槽函数connect(this->timer,SIGNAL(timeout()),this,SLOT(autoMove()));
}void GameView::autoMove()
{this->gameScene->advance();
}//当前键盘事件
void GameView::keyPressEvent(QKeyEvent *event)
{switch (event->key()){case Qt::Key_Right:this->maro->setState(0);this->gameScene->advance();break;}
}void GameView::keyReleaseEvent(QKeyEvent *event)
{
//    switch (event->key())
//    {
//    case Qt::Key_Right:
//        this->maro->setState(1);
//        this->gameScene->advance();
//        break;
//    }}

http://www.dtcms.com/wzjs/346129.html

相关文章:

  • 山西推广网站建设百度应用平台
  • wordpress分类目录和页面百度seo排名优化提高流量
  • 做爰全过程免费网站泰安网站推广优化
  • 没签合同网站做不好怎样做一个网站平台
  • 万州网站制作公司长尾关键词挖掘熊猫
  • 厦门市政府网站建设经典软文广告案例
  • 一个网站怎么上线网络广告
  • 长沙网站优化掌营天下百度百度网址大全
  • 增城网站建设公司厦门人才网
  • 长沙网站推广排名平台seo
  • 网页编成网站搜索引擎排名2020
  • 深圳做网站个人头条新闻
  • 棋牌游戏网站模板下载安装如何推广一款app
  • 怎样在在农行网站上做风险评估网站综合排名信息查询
  • 南京汽车 企业 网站建设58网络推广
  • 信息技术网站建设市场分析数据指数
  • 网站内部数据搜索怎么做做销售找客户渠道
  • 个人网站怎么建立流程线上培训平台
  • 精美合同网站建设百度查重免费
  • 动漫网页设计作业广州优化公司哪家好
  • 南昌做网站公司如何在百度发视频推广
  • 南雄网站建设武汉关键词seo排名
  • 借鉴网网站魔贝课凡seo
  • 遵义网站设计公司百度关键词搜索量排行
  • 郑州做营销型网站的公司百度关键词推广一年多少钱
  • 怎么做网站 教学seo建站公司
  • wordpress如何发布青岛seo关键词排名
  • 广东快速做网站公司哪家好搜索关键词排名
  • 高校英文网站建设成都网站优化及推广
  • 手机开发者网站百度推广自己怎么做