Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Scroll View / Displaying partly a sprite - Gideros Forum

Scroll View / Displaying partly a sprite

lsouchetlsouchet Member
edited August 2013 in Game & application design
Hi all,
I am new to Gideros, so my question may seem a bit naive.
I am building a UI and trying to insert a scroll view, i.e a frame with unlimited number of lines (sprites), but displayed only partly. On user touch events this list moves up and down but elements out of the frame are not displayed.

I didn't manage to find something like that out-of-the-box.
If you know a good library to do that simply, please stop reading and give me this reference :)

Anyway, I started to implement such a behavior, but I am stucked to this sprite cropping issue.
I need to set a shape (for example a rectangle) in which the sprite content will be displayed, without rescaling it.
For instance if I define a rectangle half as high as my sprite, only the top half of my sprite will be displayed.
How can I do such a thing?

This seems like something linked to the TextureRegion behaviour where only a part of the bitmap is displayed.
Any idea?

Thanks in advance

Dislikes: lolyoshi

+1 -1 (+0 / -1 ) Share on Facebook

Comments

  • My cheating way of doing that sort of thing is to make a graphic with the appropriately sized rectangle cut out of it and set this graphic above the things that I want to be able to cover. So, add your scroll list and then add the covering graphic and all the stuff on the scroll list will only show when it is in the cut out rectangle and disappear as it moves behind the rest of the graphic. May not be suitable for what you are doing, but that's how I've managed so far.
  • My cheating way of doing that sort of thing is to make a graphic with the appropriately sized rectangle cut out of it and set this graphic above the things that I want to be able to cover. So, add your scroll list and then add the covering graphic and all the stuff on the scroll list will only show when it is in the cut out rectangle and disappear as it moves behind the rest of the graphic. May not be suitable for what you are doing, but that's how I've managed so far.
    I thought about this, but my screen is composed with different images added one above the other so I cannot use this technique.
    So Thank you for your tip but this is not quite what I need.
  • My screen is also composed of lots of different images laid on top of each other and I can use the technique quite easily. It's just a case of adding things in the required order. I use a sprite as a holder behind the masking graphic and add any items I want to be behind the masked rectangle to that, then I the graphic with the cutout rectangle and then I add anything else that I want on top of that.
  • @petec,
    did you use render to texture?
  • @bysreg No, I just used normal graphics.
  • @petec
    I understand your point. But my window appears as a pop up so my background image appears with a little blur, and I need to take this in account. If not, my scroll item will appear between my frame window and the border of my screen.
    I would like a better solution than make an image of my background + the grey rectangle above it + the frame window and make a cutout rectangle in the middle, because then I would need to rebuild it each time my background image changes...
    Isn't there any way of cropping a sprite or defining a fixed size in which the content is displayed?
  • @Isouchet - Fair enough - didn't know what your set up is. Now I see why what I do won't work for you.
  • Hi Isouchet.
    You can implement one big texture and manipulate it by TextureRegion

    Likes: SpaceRider

    +1 -1 (+1 / -0 ) Share on Facebook
  • hi, let me point you to the 'as simple as it gets' tutorial for clipping:
    http://www.indiedb.com/tutorials/clipping-in-gideros-with-rendertarget

    it seems that you might need to use something like this to clip an area of the screen.
    at the end of the tutorial there is also a class for clipping.
  • @ar2rsawseen, thanks, would have been better, i hate self-advertising.
    on the other hand day by day there are people indirectly asking for this tutorial in different topics, so at least it seems it was worth to make it.
Sign In or Register to comment.