本文整理汇总了C++中setY函数的典型用法代码示例。如果您正苦于以下问题:C++ setY函数的具体用法?C++ setY怎么用?C++ setY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setY函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setX
/*exploser la bombe*/
void Bomb::detonateBomb(std::vector<Engin *> *asteroides){
float *coords = new float[6];
coords[0] = -0.8; coords[1] = -0.5; coords[2] = -0.2; coords[3] = 0.1; coords[4] = 0.4; coords[5] = 0.7;
float rx = coords[(rand() % 6) + 1];
float ry = coords[(rand() % 6) + 1];
for (int i = 0; i < 2; i++){
setX(rx + (((rand() % 3) - 1.0)/10.0));
setY(ry + (((rand() % 3) - 1.0) / 10.0));
draw(12, 0.3, true);
for (int j = 0; j < asteroides->size(); j++)
{
if ((abs(abs((*asteroides)[j]->getPosX()) - abs(getX())) <= 0.1)
&& (abs(abs((*asteroides)[j]->getPosY()) - abs(getY())) <= 0.1)){
if (asteroides->size()>1){ std::swap((*asteroides)[j], asteroides->back()); asteroides->pop_back(); }
}
}
}
}
开发者ID:yezideteachers,项目名称:VaisseauAsteroide,代码行数:20,代码来源:Bomb.cpp
示例2: p
void IconButton::paintEvent(QPaintEvent *e) {
Painter p(this);
auto ms = getms();
paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y(), ms, _rippleColorOverride ? &(*_rippleColorOverride)->c : nullptr);
auto down = isDown();
auto overIconOpacity = (down || forceRippled()) ? 1. : _a_over.current(getms(), isOver() ? 1. : 0.);
auto overIcon = [this] {
if (_iconOverrideOver) {
return _iconOverrideOver;
} else if (!_st.iconOver.empty()) {
return &_st.iconOver;
} else if (_iconOverride) {
return _iconOverride;
}
return &_st.icon;
};
auto justIcon = [this] {
if (_iconOverride) {
return _iconOverride;
}
return &_st.icon;
};
auto icon = (overIconOpacity == 1.) ? overIcon() : justIcon();
auto position = _st.iconPosition;
if (position.x() < 0) {
position.setX((width() - icon->width()) / 2);
}
if (position.y() < 0) {
position.setY((height() - icon->height()) / 2);
}
icon->paint(p, position, width());
if (overIconOpacity > 0. && overIconOpacity < 1.) {
auto iconOver = overIcon();
if (iconOver != icon) {
p.setOpacity(overIconOpacity);
iconOver->paint(p, position, width());
}
}
}
开发者ID:Igevorse,项目名称:tdesktop,代码行数:42,代码来源:buttons.cpp
示例3: clear
void Object::load(xml::Xml &xml)
{
clear();
/* Set attribute defaults */
xml.setDefaultString("");
xml.setDefaultInteger(0);
xml.setDefaultFloat(0);
/* Attributes ('type' is not forced to be set) */
if(xml.isInteger("x") && xml.isInteger("y"))
{
name = xml.getString("name");
type = xml.getString("type");
setX(xml.getInteger("x"));
setY(xml.getInteger("y"));
setWidth(xml.getInteger("width"));
setHeight(xml.getInteger("height"));
}
else
{
/* Throw */
throw Exception() << "Missing or wrong typed attribute";
}
/* Properties */
if(xml.toSubBlock("properties"))
{
try
{
properties.load(xml);
}
catch(Exception &exception)
{
xml.toBaseBlock();
throw Exception() << "Error whilst loading properties: " << exception.getDescription();
}
xml.toBaseBlock();
}
}
开发者ID:mrzzzrm,项目名称:shootet,代码行数:42,代码来源:Object.cpp
示例4: setX
Label::Label(string lText, int x_, int y_, int width_, int height_, const Font *font_, bool animation_, float animationSpeed_, int indent_, bool align_)
{
// Coords
setX(x_);
setY(y_);
// Width / Height
setWidth(width_);
setHeight(height_);
// Texts
setText(lText);
// Indent
setIndent(indent_);
// Animation
setAnimation(animation_);
// Invisible
setAnimatonValue(0.0f);
if(animation_)
{
// Speed
setAnimationSpeed(animationSpeed_);
}
else
{
// Speed
setAnimationSpeed(0.0f);
}
// Align
setAlign(align_);
// Font Id
font = (Font*)font_;
// Timer
animationTimer = new Timer(animationSpeed_);
}
开发者ID:CoolONEOfficial,项目名称:Character-Quest,代码行数:42,代码来源:label.cpp
示例5: setX
PainterBezier::PainterBezier(QQuickItem *parent)
:QQuickPaintedItem (parent)
,m_p1(QPointF(0.f,0.f))
,m_p2(QPointF(0.f,0.f))
,m_p3(QPointF(0.f,0.f))
,m_p4(QPointF(0.f,0.f))
,m_OutlineColor(Qt::black)
,m_FillColor(QColor(177,189,180))
,m_OutlineWidth(1.f)
,m_FillWidth(3.f)
{
setX(0);
setY(0);
setWidth(1);
setHeight(1);
setFlag(ItemHasContents, true);
//setAntialiasing(true);
setRenderTarget(QQuickPaintedItem::FramebufferObject);
setSmooth(true);
}
开发者ID:cadet,项目名称:UberQuick,代码行数:20,代码来源:PainterBezier.cpp
示例6: resetParticle
void Particle::update(float frametime)
{
if (!active)
return;
timeAlive += frametime;
if (timeAlive >= maxTimeAlive)
{
resetParticle();
return;
}
// update physics and drawing stuff
setX(getX() + velocity.x * frametime);
setY(getY() + velocity.y * frametime);
rotationValue += frametime;
if (rotationValue> 2*2.14159) //prevent overrotation
rotationValue = 0;
setRadians(rotationValue);
}
开发者ID:stuartsoft,项目名称:Rogue,代码行数:20,代码来源:particle.cpp
示例7: setLeftTopX
/**
* Update the robot values from the blob
*
* @param b The blob to update our object from.
*/
void VisualRobot::updateRobot(Blob b)
{
setLeftTopX(b.getLeftTopX());
setLeftTopY(b.getLeftTopY());
setLeftBottomX(b.getLeftBottomX());
setLeftBottomY(b.getLeftBottomY());
setRightTopX(b.getRightTopX());
setRightTopY(b.getRightTopY());
setRightBottomX(b.getRightBottomX());
setRightBottomY(b.getRightBottomY());
setX(b.getLeftTopX());
setY(b.getLeftTopY());
setWidth(dist(b.getRightTopX(), b.getRightTopY(), b.getLeftTopX(),
b.getLeftTopY()));
setHeight(dist(b.getLeftTopX(), b.getLeftTopY(), b.getLeftBottomX(),
b.getLeftBottomY()));
setCenterX(getLeftTopX() + ROUND2(getWidth() / 2));
setCenterY(getRightTopY() + ROUND2(getHeight() / 2));
setDistance(1);
}
开发者ID:WangHanbin,项目名称:nbites,代码行数:25,代码来源:VisualRobot.cpp
示例8: QGraphicsItem
/**
* @brief Connexion::Connexion Création d'une nouvelle connexion
* @param n1 Noeud d'ancrage de la connexion
* @param n2 Noeud d'ancrage de la connexion
*
* Les connexions sont à double sens et des ressources
* peuvent transiter du noeud 1 au noeud 2 et inversement.
*
* A la création un identifiant unique est défini.
*/
Connexion::Connexion(NodeConnectable &n1, NodeConnectable &n2, const GamerList &gl)
: QGraphicsItem(0), n1(n1), n2(n2), lstGamer(gl), counterAdvance(0),
stepMultiplier(1.5)
{
setNextId();
setX(n1.x());
setY(n1.y());
setZValue(1);
//Calcule de la distance de la connexion
distance = (int)sqrt(pow(n1.x()-n2.x(),2)+
pow(n1.y()-n2.y(),2));
distance -= n2.getRadius();
distance -= n1.getRadius();
pathLegth = (int)(distance/stepMultiplier);
//Connexion des noeud
n1.connect(n2.getId(), this);
n2.connect(n1.getId(), this);
}
开发者ID:LukasBitter,项目名称:P2,代码行数:30,代码来源:connexion.cpp
示例9: setX
void ffmpegWidget::mouseMoveEvent (QMouseEvent* event) {
// drag the screen around so the pixel "grabbed" stays under the cursor
if (event->buttons() & Qt::LeftButton) {
// disable automatic updates
disableUpdates = true;
setX(oldx + (int)((clickx - event->x())/this->sfx));
disableUpdates = false;
setY(oldy + (int)((clicky - event->y())/this->sfy));
event->accept();
}
// drag the grid around so the pixel "grabbed" stays under the cursor
else if (event->buttons() & Qt::RightButton) {
// disable automatic updates
disableUpdates = true;
setGx(oldgx - (int)((clickx - event->x())/this->sfx));
disableUpdates = false;
setGy(oldgy - (int)((clicky - event->y())/this->sfy));
event->accept();
}
}
开发者ID:ISISComputingGroup,项目名称:EPICS-areaDetector,代码行数:20,代码来源:ffmpegWidget.cpp
示例10: switch
void Client::gravitate(bool invert) {
int dx = 0;
int dy = 0;
int gravity = NorthWestGravity;
XSizeHints sizeHints;
XCORE->sizeHints(clientWindow_, &sizeHints);
if (sizeHints.flags & PWinGravity) {
gravity = sizeHints.win_gravity;
}
switch (gravity) {
case NorthEastGravity:
case EastGravity:
case SouthEastGravity:
dx = -borderWidth_;
break;
default:
break;
}
switch (gravity) {
case SouthWestGravity:
case SouthGravity:
case SouthEastGravity:
dy = -titleBarHeight_ - borderWidth_;
break;
default:
break;
}
if (invert) {
dx = -dx;
dy = -dy;
}
setX(x() + dx);
setY(y() + dy);
}
开发者ID:edmondas,项目名称:ncwm,代码行数:41,代码来源:client.cpp
示例11: rect
void TankGameWidget::PaintText(const ScreenText& txt, QPainter& painter)
{
if (txt.Finished())
{
return; //shall not be rendered now
}
painter.save();
painter.setPen(txt.Pen());
QFont font=painter.font();
font.setPixelSize(txt.FontSize());
font.setBold(true);
painter.setFont(font);
int rowStep=3*txt.FontSize();
if (txt.Position().x()<0 || txt.Position().y()<0)
{
int xPos=txt.Position().x();
int yPos=txt.Position().y();
if (xPos<0) xPos=0;
if (yPos<0) yPos=0;
QRect rect(xPos, yPos, m_const.boardPixelSizeFloat.x(), txt.FontSize());
for (const QString& s : txt.Text())
{
painter.drawText(rect, Qt::AlignCenter, s);
rect.setY(rect.y()+rowStep);
}
}
else
{
auto pos=ToScreen(txt.Position(), 0, 0);
for (const QString& s : txt.Text())
{
painter.drawText(pos, s);
pos.setY(pos.y()+rowStep);
}
}
painter.restore();
}
开发者ID:TheGrandmother,项目名称:cwg,代码行数:41,代码来源:tankgamewidget.cpp
示例12: setLeftTopX
/**
* Update the robot values from the blob
*
* @param b The blob to update our object from.
*/
void VisualCross::updateCross(Blob *b)
{
setLeftTopX(b->getLeftTopX());
setLeftTopY(b->getLeftTopY());
setLeftBottomX(b->getLeftBottomX());
setLeftBottomY(b->getLeftBottomY());
setRightTopX(b->getRightTopX());
setRightTopY(b->getRightTopY());
setRightBottomX(b->getRightBottomX());
setRightBottomY(b->getRightBottomY());
setX(b->getLeftTopX());
setY(b->getLeftTopY());
setWidth(dist(b->getRightTopX(), b->getRightTopY(), b->getLeftTopX(),
b->getLeftTopY()));
setHeight(dist(b->getLeftTopX(), b->getLeftTopY(), b->getLeftBottomX(),
b->getLeftBottomY()));
setCenterX(getLeftTopX() + ROUND2(getWidth() / 2));
setCenterY(getRightTopY() + ROUND2(getHeight() / 2));
setDistance(1);
setPossibleCrosses(&ConcreteCross::abstractCrossList);
}
开发者ID:AmeenaK,项目名称:nbites,代码行数:26,代码来源:VisualCross.cpp
示例13: QQmlComponent
Predator::Predator() {
component = new QQmlComponent(getEngine(), QUrl(QStringLiteral("qrc:/Predator.qml")));
if(component->status() == component->Ready) {
object = component->create(getEngine()->rootContext());
object->setProperty("parent", QVariant::fromValue(getCanvas()));
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
}
else
qDebug() << component->errorString();
setY(50 + ((double)rand()/(double)(RAND_MAX)) * (getCanvasHeight() - 100));
setX(50 + ((double)rand()/(double)(RAND_MAX)) * (getCanvasWidth() - 100));
isPredator = true;
// Randomize staring velocity to sweep
velocity.setX(2.0 + ((double)rand()/(double)(RAND_MAX)) * -4.0);
velocity.setY(2.0 + ((double)rand()/(double)(RAND_MAX)) * -4.0);
lastVel = velocity;
}
开发者ID:knorko,项目名称:Multimedior,代码行数:21,代码来源:predator.cpp
示例14: UMLWidget
/**
* Constructs a MessageWidget.
*
* This method is used for creation, synchronous and synchronous message types.
*
* @param scene The parent to this class.
* @param a The role A widget for this message.
* @param b The role B widget for this message.
* @param y The vertical position to display this message.
* @param sequenceMessageType Whether synchronous or asynchronous
* @param id A unique id used for deleting this object cleanly.
* The default (-1) will prompt generation of a new ID.
*/
MessageWidget::MessageWidget(UMLScene * scene, ObjectWidget* a, ObjectWidget* b,
int y, Uml::SequenceMessage::Enum sequenceMessageType,
Uml::ID::Type id /* = Uml::id_None */)
: UMLWidget(scene, WidgetBase::wt_Message, id)
{
init();
m_pOw[Uml::RoleType::A] = a;
m_pOw[Uml::RoleType::B] = b;
m_sequenceMessageType = sequenceMessageType;
if (m_sequenceMessageType == Uml::SequenceMessage::Creation) {
y -= m_pOw[Uml::RoleType::B]->height() / 2;
m_pOw[Uml::RoleType::B]->setY(y);
}
updateResizability();
calculateWidget();
y = y < getMinY() ? getMinY() : y;
y = y > getMaxY() ? getMaxY() : y;
setY(y);
this->activate();
}
开发者ID:Nephos,项目名称:umbrello,代码行数:34,代码来源:messagewidget.cpp
示例15: setX
//=============================================================================
// Entity bounces after collision with another entity
//=============================================================================
void Entity::bounce(VECTOR2 &collisionVector, Entity &ent)
{
VECTOR2 Vdiff = ent.getVelocity() - velocity;
VECTOR2 cUV = collisionVector; // collision unit vector
Graphics::Vector2Normalize(&cUV);
float cUVdotVdiff = Graphics::Vector2Dot(&cUV, &Vdiff);
float massRatio = 2.0f;
if (getMass() != 0)
massRatio *= (ent.getMass() / (getMass() + ent.getMass()));
// If entities are already moving apart then bounce must
// have been previously called and they are still colliding.
// Move entities apart along collisionVector
if(cUVdotVdiff > 0)
{
setX(getX() - cUV.x * massRatio);
setY(getY() - cUV.y * massRatio);
}
else
deltaV += ((massRatio * cUVdotVdiff) * cUV);
}
开发者ID:cknolla,项目名称:WichitaGame,代码行数:24,代码来源:entity.cpp
示例16: matrix_decompose
decNumber *matrix_getrc(decNumber *res, const decNumber *m) {
decNumber ydn;
int rows, cols, c, r, pos;
int n = matrix_decompose(m, &rows, &cols, NULL);
if (n < 0)
return NULL;
getY(&ydn);
pos = dn_to_int(&ydn);
pos -= n;
if (pos < 0 || pos >= rows*cols) {
err(ERR_RANGE);
return NULL;
}
c = pos % cols + 1;
r = pos / cols + 1;
int_to_dn(res, r);
int_to_dn(&ydn, c);
setY(&ydn);
return res;
}
开发者ID:BigEd,项目名称:wp34s,代码行数:21,代码来源:matrix.c
示例17: setMag
void Vector::reset(double n1, double n2, Mode form) {
mode = form;
if (form == RECT) {
x = n1;
y = n2;
setMag();
setAngle();
}
else if (form == POL) {
mag = n1;
angle = n2 / Rad_to_deg;
setX();
setY();
}
else {
cerr << "Incorrect 3rd argument to Vector -- "
<< "vector set to 0\n";
x = y = mag = angle = 0.0;
mode = RECT;
}
}
开发者ID:briansorahan,项目名称:cplusplus-primer-plus,代码行数:21,代码来源:vect.cpp
示例18: Q_UNUSED
/**
* Overrides the standard paint event.
*/
void PreconditionWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
int w = width();
int h = height();
int x = m_objectWidget->x() + m_objectWidget->width() / 2;
x -= w/2;
setX(x);
int y = this->y();
//test if y isn't above the object
if (y <= m_objectWidget->y() + m_objectWidget->height()) {
y = m_objectWidget->y() + m_objectWidget->height() + 15;
}
if (y + h >= m_objectWidget->getEndLineY()) {
y = m_objectWidget->getEndLineY() - h;
}
setY(y);
setPenFromSettings(painter);
if (UMLWidget::useFillColor()) {
painter->setBrush(UMLWidget::fillColor());
}
{
const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
const int fontHeight = fm.lineSpacing();
const QString precondition_value = QLatin1String("{ ") + name() + QLatin1String(" }");
//int middleX = w / 2;
int textStartY = (h / 2) - (fontHeight / 2);
painter->drawRoundRect(0, 0, w, h, (h * 60) / w, 60);
painter->setPen(textColor());
painter->setFont(UMLWidget::font());
painter->drawText(PRECONDITION_MARGIN, textStartY,
w - PRECONDITION_MARGIN * 2, fontHeight, Qt::AlignCenter, precondition_value);
}
UMLWidget::paint(painter, option, widget);
}
开发者ID:KDE,项目名称:umbrello,代码行数:43,代码来源:preconditionwidget.cpp
示例19: QGraphicsItem
HandleItem::HandleItem( QRect rect, QGraphicsScene *scene, const QColor color) : QGraphicsItem( 0, scene ),
m_role(HandleItem::CenterHandle),
m_color(color), m_item(new QGraphicsRectItem( rect, 0, scene ))
{
// This constructor sets up the center handle, as well as creates the other handles and links everything together.
// The center handle must know about all of the other handles so it can translate them with the object
HandleItem *topHandle = new HandleItem( m_item, color, HandleItem::TopHandle, scene );
topHandle->SetRectItem(m_item);
HandleItem *rightHandle = new HandleItem(m_item, color, HandleItem::RightHandle, scene );
rightHandle->SetRectItem(m_item);
HandleItem *leftHandle = new HandleItem( m_item, color, HandleItem::LeftHandle, scene );
leftHandle->SetRectItem(m_item);
HandleItem *bottomHandle = new HandleItem(m_item, color, HandleItem::BottomHandle, scene );
bottomHandle->SetRectItem(m_item);
m_handles.push_back(topHandle);
m_handles.push_back(rightHandle);
m_handles.push_back(leftHandle);
m_handles.push_back(bottomHandle);
topHandle->SetDependentHandles(QList<HandleItem*>() << rightHandle << leftHandle << this);
rightHandle->SetDependentHandles(QList<HandleItem*>() << topHandle << bottomHandle << this);
leftHandle->SetDependentHandles(QList<HandleItem*>() << topHandle << bottomHandle << this);
bottomHandle->SetDependentHandles(QList<HandleItem*>() << rightHandle << leftHandle << this);
this->SetDependentHandles(QList<HandleItem*>() << rightHandle << leftHandle << topHandle << bottomHandle);
SetDefaults();
setX(m_item->rect().left() + m_item->rect().width() / 2 - HandleRadius);
setY(m_item->rect().y() + m_item->rect().height() / 2 - HandleRadius);
}
开发者ID:daviddoria,项目名称:QtHandleItem,代码行数:40,代码来源:HandleItem.cpp
示例20: setY
void Player::collidePlatform(GameObject& p)
{
// "Latch" onto a platform if we land onto it
if(y() + m_anims.currentAnim().frame().h - p.y() <= 4 && m_jumpState != Jumping)
{
setY(p.y() - height());
if(m_jumpState == Falling)
{
m_anims.setCurrentAnim(m_direction == 1 ? "land_right" : "land_left");
m_jumpState = Landing;
m_landSound.play();
}
else if(m_jumpState == Landing && m_anims.currentAnim().currentFrameNumber() == m_anims.currentAnim().frameCount() - 1)
{
m_anims.setCurrentAnim(m_direction == 1 ? (m_moveForward ? "run_right" : "wait_right") : (m_moveForward ? "run_left" : "wait_left"));
m_jumpState = Standing;
}
m_fallSpeed = 0;
m_currentPlatformStart = p.x();
m_currentPlatformEnd = p.x() + p.width();
}
}
开发者ID:10098,项目名称:braveball,代码行数:22,代码来源:player.cpp
注:本文中的setY函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论