Jump to content

Overflow:hidden slider


Recommended Posts

Hi again,

I'm in the process of building a sort of slider inside the game and was wondering the best way to approach this.

Normally in html/css I would define a div with a hidden overflow with a set width/height and then move objects inside.


Maybe I've been too focussed on css, but I am hoping there is a way to do a similar thing in Phaser.

If not what would be the best approach?



Link to comment
Share on other sites

My vision:

The slider's sliding part is a sprite, the background is an attached sprite (generated with the slider).

The update function of this sprite is empty.

Fire an event on click of the sliding part.

This event will erase the sprite's update function with a new one:

In this update: Sprite.position.x = pointer.position.x

Once the finger is no longer touching, fire a new event that will erase the update function with an empty one.


You could also just use a bool in the update (in order to know if the sprite is beeing dragged or not) but I guess it's less optimized.

Also, don't forget to set a max x position.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...