SFML community forums
Help => General => Topic started by: terrifiedobama on June 26, 2019, 10:15:52 pm
-
i need help, i've been stuggling since 1 day figure this out
◘◘◘◘Halp plox, i've been Stuggling for (3) {days} trying to figure this out◘◘◘◘
whenever i try to write
for (int t = 0;t <= 5;t++) {
PlayerSprite.move(sf::Vector2f(0,0.1));
if (PlayerSprite.getGlobalBounds().intersects(Tile001Sprite.getGlobalBounds)) {
std::cout << "tes" << std::endl;
}
}
the following error is : Severity Code Description Project File Line Suppression State
Error C3867 'sf::Sprite::getGlobalBounds': non-standard syntax; use '&' to create a pointer to member
ive been stuggling alot if someone can help me i will apriciate it alot :-[
i cant write the PlayerSprite i dont understand what does this pointer & mean like where should i put it like i dont understand im mega confused im really confused.
-
Is that the only place you use getGlobalBounds() ? I can't see the line numbers in the image to see if you're looking at the line mentioned in the error. This error usually means you forgot to put the () at the end of a function call (and confuses it with a malformed function pointer).
-
if (PlayerSprite.getGlobalBounds().intersects(Tile001Sprite.getGlobalBounds)) {
-
this is the full code...........
----------------------------------
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow Window(sf::VideoMode(800, 600), "My window" , sf::Style::Close);
Window.setTitle("NULL Title");
sf::Vector2u size = Window.getSize();
unsigned int Width = size.x;
unsigned int Height = size.y;
Window.setSize(sf::Vector2u(999,777));
Window.setPosition(sf::Vector2i(300,20));
sf::WindowHandle handle = Window.getSystemHandle();
Window.setVerticalSyncEnabled(true);
//window.setFramerateLimit(60);
sf::Event event;
sf::Texture textureone;
sf::Sprite spriteone;
sf::Texture texturetwo;
sf::Sprite spritetwo;
while (Window.isOpen()) {
sf::Event event;
if (Window.pollEvent(event))
{
if (event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape)
Window.close();
}
Window.display();
if (!textureone.loadFromFile("hs.png", sf::IntRect(111,111,111,111))) {
std::cout << "nope" << std::endl;
}
//else
//(std::cout << "yes" << std::endl);
spriteone.setTexture(textureone);
if (!texturetwo.loadFromFile("hs2.png", sf::IntRect(111, 111, 111, 111))) {
std::cout << "nope2" << std::endl;
}
spritetwo.setTexture(texturetwo);
//spritetwo.setPosition(sf::Vector2f(333,333));
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
spritetwo.move(3,0);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
spritetwo.move(-3, 0);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {
spritetwo.move(0, 3);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {
spritetwo.move(0, -3);
}
if (spriteone.getLocalBounds().intersects(spritetwo.getGlobalBounds)) {
}
Window.clear(sf::Color::White);
Window.draw(spriteone);
Window.draw(spritetwo);
}
return 0;
}
-
i still get that pointer error :@ :(
-
getGlobalBounds should be getGlobalBounds()
getGlobalBounds() is the method call. getGlobalBounds is the address of that method.
-
Tnx bro im new to coding
im very stupid sorry
big tnx bro
-
No worries. I still get this error a lot ;D