Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Need Help  (Read 2868 times)

0 Members and 1 Guest are viewing this topic.

georgemarian

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Need Help
« on: April 15, 2017, 10:31:24 pm »
Hello ,i recently i got into sfml and i steped into a problem.

i have 2 shape classes and i want to know when they collide with each other using

if(ObjClass1.getGlobalBounds().intersets(ObjClass2.getGlobalBounds()))
{
//instruncions
}
but it's not working in any type or form.I would appreaciate a tip  ;D

JayhawkZombie

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Need Help
« Reply #1 on: April 15, 2017, 10:52:43 pm »
This probably belongs in https://en.sfml-dev.org/forums/index.php?board=4.0

But in any case, how are you defining "getGlobalBounds" for your classes?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Need Help
« Reply #2 on: April 16, 2017, 07:20:02 am »
"It's not working" is never a problem description. What is your expectation and what is actually happening.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

georgemarian

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Need Help
« Reply #3 on: April 16, 2017, 06:59:41 pm »
Sorry i am new to this forum :D.

getGlobalBounds() is a float react type .





eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Need Help
« Reply #4 on: April 16, 2017, 08:05:21 pm »
And what do you mean by that?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

JayhawkZombie

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Need Help
« Reply #5 on: April 16, 2017, 08:36:14 pm »
How are you implementing it for your class?  sf::FloatRect assumes (left, top, width, height), so like 

sf::FloatRect getGlobalBounds()
{
  return sf::FloatRect(
    Position.x, //left
    Position.y, //top
    Size.x,     //width
    Size.y      //height
  );
}

theonekamisama

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Need Help
« Reply #6 on: April 21, 2017, 09:11:22 am »
you will have to be more specific like what's happening?

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: Need Help
« Reply #7 on: April 21, 2017, 04:04:58 pm »
Hi

Please make sure, if you are expecting that the Intersects() method returns 'true', that both Rectangles (FloatRect) really collide, and that you have implemented them correctly as members of your classes.

If you can send your code here I'll try to look for how you can get what you need (if the code is in C#, better for me)