To efficiently use texture memory and processing power of GPUs, applications should use low-resolution images on devices with low-resolution screens and high-resolution images on devices with high-resolution screens. There are multiple resolutions that game developers should consider. new () local textureRegion = texturePack : getTextureRegion ( “ 1. Displaying texture regions is the same as displaying textures: create a Bitmap object that wraps the TextureRegion object: It is used to define independent texture regions within a texture atlas. The TextureRegion class specifies a texture and a rectangular region in it. Using texture atlases instead of individual textures helps in reducing bind operations. ![]() ![]() Rendering from a texture atlas is usually faster.Įach texture is bound to OpenGL just before rendering it and binding is a costly operation. Texture atlases usually have power-of-two dimensions and therefore don’t need to be enlarged.Ģ. That’s where the texture atlas becomes handy. For example, an image with dimensions of 100x200 becomes a texture with dimensions of 128x256 in memory. Gideros automatically increase the texture size to conform to this rule. To use an image as a texture, its width and height always have to be a power of two. Texture atlases usually consume less memory. There are two main reasons for using a texture atlas instead of many independent textures:ġ. When Gideros starts, the display list hierarchy contains one item (the global Stage instance) only and we can add more: You can access this global variable with the name stage. The root of the scene tree is an instance of the Stage class which is automatically created and set as a global variable when Gideros starts. The scene tree is the hierarchy of all graphical objects currently displayed and this hierarchy needs a root. Therefore if you add a child object that already has a different sprite as a parent, the sprite is removed from the child list of the other sprite and then added to this sprite. new () - Add the new Sprite as a child : mySprite : addChild ( childSprite ) - Set the position : mySprite : setPosition ( 10, 20 ) - Set the scaling : mySprite : setScale ( 0.5, 1 ) - Set the rotation angle : mySprite : setRotation ( 90 ) - Set the alpha transparency : mySprite : setAlpha ( 0.7 ) - Get the first child : mySprite : getChildAt ( 1 ) - Remove the child : mySprite : removeChild ( childSprite ) Create a new Sprite instance : local childSprite = Sprite. Hierarchy is an important feature in graphics - when you move your parent sprite, all the child (and grandchild) sprites also move simultaneously. Sprites can have other sprites as their children and these children inherit properties such as position, scaling, and transparency from their parent sprite. ![]() It’s the main construction element and used to create display hierarchies. Sprite is the base class of all display classes and has no visual representation. Sprite class is used to group and transform these instances. For example, the Bitmap class is used to display bitmap graphics, and TextField is used to display text object. In Gideros Studio, all graphical content is constructed by creating graphical instances and adding them to the scene tree. Graphics and animation Introduction to graphics
0 Comments
Leave a Reply. |