本文整理汇总了C++中GImage::setLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ GImage::setLocation方法的具体用法?C++ GImage::setLocation怎么用?C++ GImage::setLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GImage
的用法示例。
在下文中一共展示了GImage::setLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMove
bool MarbleGraphics::makeMove(const Move move){
GImage * movingMarble = marbles[move.startRow][move.startCol];
int jumpedRow = move.startRow+(move.endRow-move.startRow)/2;
int jumpedCol = move.startCol+(move.endCol-move.startCol)/2;
GImage * jumpedMarble = marbles[jumpedRow][jumpedCol];
if (movingMarble == NULL || jumpedMarble == NULL){
return false;
}
//Move empty spot from end to start of move
GOval* endSpot = spaces[move.endRow][move.endCol];
double tempX = endSpot->getX();
double tempY = endSpot->getY();
endSpot->setLocation(movingMarble->getX(), movingMarble->getY());
spaces[move.startRow][move.startCol] = endSpot;
spaces[move.endRow][move.endCol] = NULL;
spaceCoords[endSpot] = Coord(move.startRow, move.startCol);
//Move image at start location to image at end location
movingMarble->setLocation(tempX, tempY);
marbles[move.endRow][move.endCol] = movingMarble;
marbles[move.startRow][move.startCol] = NULL;
marbleCoords[movingMarble] = Coord(move.endRow, move.endCol);
//Delete marble for jumped space and create empty space there instead
marbles[jumpedRow][jumpedCol] = NULL;
marbleCoords.remove(jumpedMarble);
remove(jumpedMarble);
delete jumpedMarble;
GOval* jumpedSpace = new GOval(kMarbleDimension, kMarbleDimension);
spaces[jumpedRow][jumpedCol] = jumpedSpace;
spaceCoords[jumpedSpace] = Coord(jumpedRow, jumpedCol);
add(jumpedSpace, jumpedCol*(kMarbleDimension+kMarbleSpacingWidth)+kMarbleSpacingWidth,
jumpedRow*(kMarbleDimension+kMarbleSpacingWidth)+kMarbleSpacingWidth);
return true;
}
示例2: test_contains_and_getBounds
void test_contains_and_getBounds() {
bool useCompounds = false;
int x0 = 350;
int y0 = 300;
Map<string, GObject*> shapeMap;
GOval *oval = new GOval(x0, y0, 200, 100);
GRoundRect *roundRect = new GRoundRect(x0, y0, 200, 100, 300);
roundRect->setLineWidth(20);
G3DRect *rect3d = new G3DRect(x0, y0, 200, 100, true);
//rect3d->setLineWidth(5);
rect3d->setFillColor("green");
rect3d->setFilled(true);
GPolygon *poly = new GPolygon;
poly->addVertex(0, 0);
poly->addEdge(200, 100);
poly->addEdge(-200, 0);
poly->setLocation(x0, y0);
GPolygon *cpoly = new GPolygon;
cpoly->addVertex(0, 0);
cpoly->addEdge(200, 100);
cpoly->addEdge(0, -100);
cpoly->addEdge(-200, 100);
cpoly->setLocation(x0, y0);
GRect *rect = new GRect(x0, y0, 200, 100);
GLine *line = new GLine(x0, y0, x0 + 200, y0 + 100);
GLabel *label = new GLabel("Ostromantus", x0, y0);
GArc *arc = new GArc(x0, y0, 350, 350, 0, 90);
//arc->setLineWidth(5);
arc->setColor("#44000000");
GArc *filledArc = new GArc(x0, y0, 350, 100, 45, 225);
filledArc->setFillColor("#88e0e0e0");
filledArc->setFilled(true);
GCompound *comp1 = new GCompound;
comp1->setLocation(x0, y0);
comp1->add(new GLabel("compound", 0, 15));
GRect *bgRect1 = new GRect(0, 0);
gw->add(bgRect1);
bgRect1->setFillColor("#55dddddd");
bgRect1->setFilled(true);
GImage *image = new GImage("homer-transparent.png");
image->setLocation(x0, y0);
GCompound *comp = new GCompound;
comp->setLocation(x0, y0);
GRect *compRect = new GRect(20, 20, 100, 100);
GOval *compOval = new GOval(90, 90, 150, 70);
comp->add(compRect);
comp->add(compOval);
GButton *button = new GButton("Testo");
button->setSize(200, 100);
button->setLocation(x0, y0);
shapeMap.put("oval", oval);
shapeMap.put("rounded rectangle", roundRect);
shapeMap.put("3D rectangle", rect3d);
shapeMap.put("polygon", poly);
shapeMap.put("crazy polygon", cpoly);
shapeMap.put("rectangle", rect);
shapeMap.put("line", line);
shapeMap.put("arc", arc);
shapeMap.put("filled arc", filledArc);
shapeMap.put("label", label);
shapeMap.put("image", image);
shapeMap.put("compound", comp);
shapeMap.put("button", button);
GObject *currObj;
GChooser *ch = new GChooser;
ch->setActionCommand("chooser");
ch->addItem("oval");
ch->addItem("rounded rectangle");
ch->addItem(("3D rectangle"));
ch->addItem("polygon");
ch->addItem("crazy polygon");
ch->addItem("rectangle");
ch->addItem("line");
ch->addItem("arc");
ch->addItem("filled arc");
ch->addItem("label");
ch->addItem("image");
ch->addItem("compound");
ch->addItem("button");
ch->setSelectedItem("rectangle");
currObj = rect;
GButton *endButton = new GButton("End test");
GButton *fillButton = new GButton("Auto-fill");
GButton *rotateButton = new GButton("Rotate");
GButton *scaleButton = new GButton("Scale");
GCheckBox *compCheckbox = new GCheckBox("compounds");
compCheckbox->setActionCommand("compounds");
gw->addToRegion(compCheckbox, "north");
gw->addToRegion(ch, "north");
gw->addToRegion(rotateButton, "north");
gw->addToRegion(scaleButton, "north");
gw->addToRegion(fillButton, "north");
gw->addToRegion(endButton, "north");
while (true) {
GEvent e = waitForEvent(ACTION_EVENT | MOUSE_EVENT);
if (!e.isValid())
//.........这里部分代码省略.........