您好编写了一个有趣的程序来练习sfml。我制作了dvd徽标屏幕(该屏幕从一个点跳到另一个,但我想检查它是否在拐角处发生碰撞,以便更改颜色。如何检查它是否与拐角处发生碰撞?
window.clear();
window.draw(shape);
if (x_direction==1){
shape.move(0.05,0);
}
if (x_direction==2){
shape.move(-0.05,0);
}
if (y_direction==1){
shape.move(0,0.05);
}
if (y_direction==2){
shape.move(0,-0.05);
}
if (shape.getPosition()==)
//draw objects here
window.display();
if (shape.getPosition().x + shape.getLocalBounds().width >= window.getSize().x ) {
x_direction =2;
}
if (shape.getPosition().x <= 0 ) {
x_direction=1;
}
if (shape.getPosition().y <= 0 ) {
y_direction=1;
}
if (shape.getPosition().y + shape.getLocalBounds().height >= window.getSize().y ) {
y_direction=2;
}
}
return EXIT_SUCCESS;
}
尝试使用get Position,但这会受到对象大小的影响吗?