HuePig 0 Light Poster

Hi,

I'm trying to scroll my texture using sprite.setTextureRect(sf::IntRect(10, y_axis, 800, 600)). In my update I increment y_axis++, but then the image wont show.

Heres the structure so far:

init(){
    if (!starField.loadFromFile("image/starfield.jpg", sf::IntRect(10, 10, 800, 600))){}
    s_starField.setTexture(starField);
    y_axis = 0;
}

update(){
    y_axis++; 
    s_starField.setTextureRect(sf::IntRect(10, y_axis, 800, 600));
}

render(){
    windows->Draw(s_starField);
}

main(){
    //window initialization here

    init();

    while(window->isOpen()){
        Render();
        Input();
        update();
    }
}

whats the problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.