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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Jan666

Pages: 1 ... 3 4 [5]
61
Graphics / Re: Constructor problem, need help
« on: May 09, 2022, 10:28:21 pm »
It says: temp.c:(text+0x134):undefined reference to 'buttons::buttons... to everything, i made this via mobilephone c4droid, hmm is it a constructor fault or the fault depends on this programm?

62
Graphics / Constructor problem, need help
« on: May 09, 2022, 09:32:18 pm »
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);
       
 }

63
Graphics / Re: Touch Button
« on: March 23, 2022, 12:45:51 pm »
Okay Sometimes is the best when you Help yourself and dont ask in a Dead Forum. So In case someone has the same problem, here is the Solution:

Vector2f buttonSize (300, 300);
Vector2f buttonPosition (100, 800);

RectangleShape Button;
Button.setSize(buttonSize);
Button.setPosition(buttonPosition);

FloatRect buttonTouch (buttonPosition, buttonSize);

if(buttonTouch.contains(Touch::getPosition(0).x, Touch::getPosition(0).y){

    //Set the other rectangle fill with Color
}

64
Graphics / Touch Button
« on: March 22, 2022, 01:23:05 pm »
Hi i am searching the Code for a simple Exercise, maybe someone can help me. I work with  sf::Touch, let me explain what i need:
I have 2 RectableShapes  and now i want to use one for a button. If i touch the ButtonRectable the Color change by Rectable Nr.2?


Pages: 1 ... 3 4 [5]