
#Gideros or update
įunction update R ender : when this function is called, the renderTarget texture is cleared first with color 0 and alpha 0, so it is completely empty, then toRender is drawn to renderTarget, which draws every child (and grandchild, etc.) of the dummy object toRender on renderTarget. This way whatever is drawn on renderTarget, it is applied as a texture to render and at the end it is put on screen as render is added to stage.

Line 3: render is a Bitmap generated with the texture renderTarget. Its size is half of the screen (320x240) and the last parameter true allows antialiasing of this texture. Line 2: renderTarget is a new RenderTarget object, which is in fact a texture, that can be used as a texture to make a bitmap from it or even arbitrary shapes could use it, this way we can achieve complicated clippings very easily, we don't need to restrict ourselves to rectangular clippings. Notice that this dummy is not even added to the stage. Line 1: toRender is a dummy Sprite, all the sprites that we want to clip will be added as a child to this Sprite instead of the stage. RenderTarget=RenderTarget.new(320, 240, true)
#Gideros or code
See for reference about the usage of renderTarget.įirst we add the following code right before the for cycle: toRender=Sprite.new() In this step we change the code in the following ways. Local info = TextField.new(nil, "drag the shapes around with your mouse or fingers") Shape:addEventListener(Event.MOUSE_UP, onMouseUp, shape) Shape:addEventListener(Event.MOUSE_MOVE, onMouseMove, shape) Shape:addEventListener(Event.MOUSE_DOWN, onMouseDown, shape) Shape:setFillStyle(Shape.SOLID, 0xff0000, 0.5) If self:hitTestPoint(event.x, event.y) then [[ĭrag the shapes around with your mouse or fingers In a nutshell, it puts 5 rectangular shapes in random positions and attaches mouse event handlers to each of them so that they are draggable. From now on we assume that you are familiar with this example and know how it works, so experiment a bit with it if you need. You should open it or start a new project with the same properties (320x480 logical dimensions etc.) and copy the code below. The set-upįor simplicity we modify an example that comes with Gideros, the Drag Me example.
#Gideros or free
This tutorial was made during the Sharebruary program of Gideros offering free limited licence for people creating tutorials during February of 2014, more info here:. I think reading this tutorial is also a good way to understand better some other features of Gideros (object oriented programming, sprite hierarchy, etc.).

.jpg)
This tutorial should help you to use renderTarget in many other ways as well, not just simple clipping. As it's not evident how, I decided to make this tutorial to explain the details. On the other hand with the renderTarget feature you can actually do any kind of clipping. In Gideros you can do many things very simply and fast, yet clipping is an important feature that is not yet implemented in a straightforward way.
#Gideros or how to
Nevertheless this tutorial remains to be a good introduction on how to use renderTarget. Remark: since the original publication of this tutorial, real clipping capability was added to Gideros, thus now it's easy to clip using the Sprite:setClip function, see details. This tutorial is assuming a beginner level knowledge of Gideros, although if you are familiar with any programming language/framework, you should be able to understand most of the codes and the tutorial. To start to develop your games in Gideros for free, go to. Gideros is a cross-platform mobile lua rapid game-development framework (currently for android/ios). This is a tutorial about how to use renderTarget in Gideros, especially to achieve clipping. Tutorial: Clipping in Gideros with renderTarget
