SFML community forums
Help => General => Topic started by: ntrncx on November 19, 2011, 11:16:38 pm
-
Hey all
Thats my second project and i am really new in all this,i study c++ for hobby.
Now to my problem if you can help me with documentation or advices will be apreciated :D
i use SFML obviously and this for animation http://www.sfml-dev.org/wiki/en/sources/frame_anim_animated
i have an animation and i want to be able to click it with the mouse where ever will be.
for mouse click i use that :
if(events.Type == events.MouseButtonReleased && events.MouseButton.Button == sf::Mouse::Left)
if((input.GetMouseX()>=Tr.x && input.GetMouseX()<=Bl.x) && (input.GetMouseX()>=Bl.y && input.GetMouseY()<=Bl.y))
{
App.Close(); // thats just for testing to see that if actually works,but it doesnt
}
the coordination is right Tr stands for top right corner and Bl for bottom left
in main i have that
for(int loop=totalBalloons-1;loop>=0;loop--)
{
BALLOONS[loop].Move(0,yAxis);
topLeftCorner=BALLOONS[loop].GetPosition();
bottomRightCorner.x=topLeftCorner.x+50;
bottomRightCorner.y=topLeftCorner.y+65;
App.Draw(BALLOONS[loop]);
BALLOONS[loop].Update();
}
i am almost sure that the problem is that the animations are inside vectors .
so they share things,any suggestions?
thanks for your time :D
-
your if statement is wrong
if((input.GetMouseX()>=Tr.x && input.GetMouseX()<=Bl.x) && (input.GetMouseX()>=Bl.y && input.GetMouseY()<=Bl.y))
and by putting this in the loop
topLeftCorner=BALLOONS[loop].GetPosition();
bottomRightCorner.x=topLeftCorner.x+50;
bottomRightCorner.y=topLeftCorner.y+65;
you are overwriting the values each iteration of the loop.
I can't help you much more than that because you have only included two snippets of your code that don't even seem to go together (is Tl short for topLeftCorner??)
-
yes Tl means that,thanks a lot i solved the problem
what i did wrong wast hat the following code was inside a function
if(events.Type == events.MouseButtonReleased && events.MouseButton.Button == sf::Mouse::Left)
if((input.GetMouseX()>=Tr.x && input.GetMouseX()<=Bl.x) && (input.GetMouseX()>=Bl.y && input.GetMouseY()<=Bl.y))
{
App.Close(); // thats just for testing to see that if actually works,but it doesnt
}
i put it out and worked as a charm :D
and thanks a lot for the observation about the repeating code,i try to learn :D[/code]