Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Any way to "crop" a sprite? — Gideros Forum

Any way to "crop" a sprite?

krl3000krl3000 Member
edited September 2013 in General questions
I can tell I'm going to have lots of questions as I get more familiar with Gideros. It's a great product though.

Is there any way to "crop" a sprite? I have a sprite that contains other sprites. I'd like the child sprites to move within the parent but have them be able to move out of view, so to speak, by moving past the parent sprite's height, width, x, or y bounds. Imagine a window in a wall with someone walking past the window on the other side of the wall. In my specific case, I'm sliding one object down out of view while simultaneously sliding another one down into view.

Since the SceneManager already has an animation like this, I've been modifying it so it can be added to another sprite instead of the stage. I was hoping that sprites would keep their initial dimensions, but it appears from stepping through the SceneManager animation that as the two scenes move within my parent sprite the parent sprite's height is increasing. In my case, since the two scene's are the same size as the parent initially, I'm seeing each frame change the parent sprite's height to 2X, 3X, etc.

Is there a way to keep a sprite's dimensions from changing? I didn't see "setHeight()" or "setWidth()" methods in the Sprite.

The only options I can see right now are to either scrap this approach entirely and write my own animation -- probably involving some sort of scaling on the two child sprites -- or put some sort of full-screen overlay on the scene with transparent areas where I'm trying to move the child sprites. Since the locations of those areas aren't static and can be of variable size, that might not be easy.

Any thoughts?

Comments

  • @krl3000
    Another way would be to use render to texture.
    You can create the RenderTarget object with needed dimensions and render all the sprite hierarchy in it as needed. :)
  • I'll look into that. Thanks.
  • Thanks again for the suggestion. This question came from me trying to figure out ways to solve a previous question of mine (creating a sprite to simulate a 3D rotating cube with different images on each surface). To be precise, I only needed 3 surfaces and was only rotating on the Z-axis.

    I think I've come up with a "good enough" solution for now based on my idea of using SceneManager. I'm ignoring the issue above right now since it's really a bit of a distraction from what I was trying to accomplish. I just discovered it because I was using one of the existing "Move" translations to test my SceneManager modifications. For the real code, I needed to write a new translation function to create a single-axis rotating effect. I've done that and while it doesn't have the appropriate 3D perspective, it looks fairly good and probably good enough for my needs.

    I described this more fully on my original question. The code for the new translations is posted there:

    http://www.giderosmobile.com/forum/discussion/3775/is-it-possible-to-flip-a-sprite-with-a-3d-effect#Item_10
  • I do this almost daily. I use an imaging sdk found on the internet which can crop images found on the internet . Install it and it becomes a selectable processing option.Then you can crop images in any program at all, including Adobe Acrobat . Just open the images, select crop ,and follow the setps given in the sdk, the task will be finished in several seconds. if you haven't found a good choice , you can have a try. best wishes.
    http://www.rasteredge.com/how-to/vb-net-imaging/crop-image/
Sign In or Register to comment.