vortitri.blogg.se

Gideros set sprite of texture
Gideros set sprite of texture











gideros set sprite of texture

So the scaling factor for a device with screen resolution 320x480 (older iPhones) is 1, scaling factor for 480x960 (iPhone 4) is 2 and scaling factor for 480x800 (Samsung Galaxy S) is around 1.5.

gideros set sprite of texture

In this example, our logical dimensions are 320x480 and scale mode is Letterbox. Now right click on the project name and select “Properties…” to understand how we configure automatic image resolution parameters: As you can see, for the different resolutions, the original 200x200 image or high-resolution variants (300x300 and 400x400) are selected and displayed automatically. Run this example multiple times by selecting different resolutions on Gideros Player such as 320x480, 640x960, and 480x800. Open the project “Hardware/Automatic Image Resolution” to see automatic image resolution in action. For example, if your screen is automatically scaled by 2, then using the double-sized image is the best choice in terms of quality and efficiency. With the help of automatic image resolution, you can bundle both low and high-resolution images together with your application and Gideros automatically selects the best resolution according to your scaling.Īutomatic image resolution is directly related to automatic screen scaling. 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.

gideros set sprite of texture

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

  • 5.3 Getting Texture Regions from Texture Packs.
  • 5.2.1 Dynamic Creation of Texture Packs.












  • Gideros set sprite of texture