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 - 0026sd

Pages: [1]
1
Graphics / Re: Text Effects
« on: June 06, 2013, 07:54:46 pm »
Hey everyone!!

Just a general question of which I cannot adequately find an answer for within the forum (or on Google).

I'm creating a menu with menu entries and I want to add a text effect to the menu entry when it's hovered over. This can be anything like a glow, outline, what-have-you. I feel like it would be so much less overhead than creating 2 images of every menu entry I have if I could check if the mouse was colliding with the entry and, if so, call a hover() on it or something.

SO! My question is, is this possible through SFML? I looked through parts of the Graphics module in the documentation but didn't see what I was looking for... perhaps I was looking in the wrong place.

Any tips/advice would be very much appreciated.

Thanks,
Scott.

SFML does not provide any way to do this directly. SFML provides building blocks that you can use to implement effects like this. One way to do this would be through a shader, another way as you guessed would be to create multiple textures of your buttons.

Ah, yes I read briefly about shaders and wondered if that was a viable option. Thanks for your advice!

2
Graphics / Text Effects
« on: June 06, 2013, 06:08:03 pm »
Hey everyone!!

Just a general question of which I cannot adequately find an answer for within the forum (or on Google).

I'm creating a menu with menu entries and I want to add a text effect to the menu entry when it's hovered over. This can be anything like a glow, outline, what-have-you. I feel like it would be so much less overhead than creating 2 images of every menu entry I have if I could check if the mouse was colliding with the entry and, if so, call a hover() on it or something.

SO! My question is, is this possible through SFML? I looked through parts of the Graphics module in the documentation but didn't see what I was looking for... perhaps I was looking in the wrong place.

Any tips/advice would be very much appreciated.

Thanks,
Scott.

3
Window / Re: Handling keyPressed event in player's update method (SFML 1.6)
« on: November 06, 2012, 05:19:18 pm »
Should be
Event.Key.Code
, not
Event.KeyPressed
read the events tutorial. And consider upgrading to 2.0

I have read the tutorials and I'm scared to upgrade to 2.0.. haha. Or lazy.

Anyway, thanks for the suggestion but I actually tried that and it didn't work either. The problem is that the tutorials use the events in cooperation with the RenderWindow initialization whereas I want to use it in a separate class from that.

4
Window / Handling keyPressed event in player's update method (SFML 1.6)
« on: November 06, 2012, 05:00:43 pm »
Hi everyone,

How can I execute code if a key has been pressed inside my Player class' update method?

The issue is that I'm currently using window.GetInput().IsKeyDown(sf::Key::whatever) for the player's movement and jumping but I need only to get the keyPressed when the player fires (so he doesn't spam bullets as long as the space bar is down).

I've tried adding an Event to the method and polling it but it doesn't respond to anything. Please have a look at this simplified code:

Main.cpp
#include <SFML/Graphics.hpp>
#include <iostream>
#include "Level.h"

int main()
{
   
    sf::RenderWindow window(sf::VideoMode(500, 300, 32), "SFML KeyPressed");
    window.UseVerticalSync(true);

    Level level;
    level.Initialize();
    level.LoadContent();

    while(window.IsOpened())
    {

        sf::Event Event;
        while(window.GetEvent(Event))
        {

             if(Event.Type == sf::Event::Closed)
                 window.Close();

        }

        level.Update(window);

        window.Clear();

        level.Draw(window);

        window.Display();

    }

    return 0;

}

I won't include the Level class. It basically creates a Player object and calls the player's init, load, update, draw methods in the same way main.cpp does with level.

Player.cpp

// ...

void Player::Update(sf::RenderWindow &window)
{

    // Check for movement
    if(window.GetInput().IsKeyDown(sf::Key::Left))
        movement = -1.0f;
    else if(window.GetInput().IsKeyDown(sf::Key::Right))
        movement = 1.0f;

    // Check for shooting - this is where I only need the key to fire once...
    sf::Event Event;
    while(window.GetEvent(Event))
    {
        if(Event.KeyPressed == sf::Key::Space)
            Shoot();
    }

    // ...

}

// ...

 

Pages: [1]
anything