Hi, can someone help me with this following Problem, i wanna make a touch game on android, so i beginn with three touch buttons. I dont know why its not working, any Construcor problem
main.cpp:
#include <SFML/Graphics.hpp>
#include "buttons.h"
#include <iostream>
using namespace sf;
using namespace std;
int main(int argc, char *argv[])
{
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "Hello SFML");
buttons btn("buttons.png");
btn.btnInit (3.0, 3.0, 300.0, 250.0, 500.0, 700.0);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event));
window.clear(sf::Color(0, 0, 0));
btn.btnDraw(window);
window.display();
}
return 0;
}
Button.h:
#ifndef BUTTONS_H
#define BUTTONS_H
#include <SFML/Graphics.hpp>
using namespace sf;
using namespace std;
class buttons {
public :
buttons(string btnPng);
void btnInit(float btnScaleX, float btnScaleY, float btnPosX, float btnLeftPosY, float btnRightPosY, float btnFirePosY);
void btnDraw(RenderWindow &window);
private:
Sprite btnSprite;
Texture btnText;
};
#endif
and Buttons.cpp:
#include <SFML/Graphics.hpp>
#include <iostream>
#include "buttons.h"
using namespace sf;
using namespace std;
buttons::buttons()
{
}
buttons::buttons(string btnPng){
btnText.loadFromFile(btnPng);
btnSprite.setTexture(btnText);
}
void buttons::btnInit(float btnScaleX, float btnScaleY, float btnPosX, float btnLeftPosY, float btnRightPosY, float btnFirePosY){
btnSprite.setScale(btnScaleX, btnScaleY);
btnSprite.setPosition(btnPosX, btnLeftPosY);
btnSprite.setPosition(btnPosX, btnRightPosY);
btnSprite.setPosition(btnPosX, btnFirePosY);
}
void buttons::btnDraw(RenderWindow &window){
window.draw(btnSprite);
window.draw(btnSprite);
window.draw(btnSprite);
}