"Open source Java Game Framework Libgdx theme" -11-Core Library-Actor class

Source: Internet
Author: User
Tags clear screen event listener libgdx

Actor class, also known as actor class, is the most basic element in LIBGDX development and can be inherited. Actor class, from the perspective of OpenGL class, can be called a two-dimensional scene node. It itself has a common approach to properties such as position (postion), bounding rectangle (similar to retangle), Anchor point (Origin), scaling (scale), rotation (rotation), color, and so on: Act (float Delta) : Update the state of the actors in the game, often called in render, parameters are generally passed into the game render interval time. Addaction (Action action): Adding an action, adding a simple animation to the actor Addcapturelistener (EventListener listener): Adding a Capture listener, an object passed in as an event listener , which is used to listen for events during capture. AddListener (EventListener Listener): Add Listener Clear (): Empties all listeners added by the current actor Clearlisteners (): Empties all listeners added by the current actor Clipbegin () : Crop current actor clipbegin (float x,float y,float width,float height): Crop current actor based on incoming rectangle clipend (): End cropping debug (): Debug method Draw (Batch batch , float Parentalpha): Draw Current actor Fire (event event): Sets the current actor as the event target actor, if necessary, passes the event in the argument to the parent of the current actor getactions (): Gets all the actions that are added to the current actor, The return type is a list-type variable getcolor (): Gets the current color Getdebug (): The return type is a Boolean variable that confirms whether the actor has been debugged GetHeight (): Gets the height of the actor getlisteners () : Gets all listeners currently added, return type is a list type variable getname (): Gets the name of the current actor, mates with SetName (String name) using
1  PackageCom.mygdx.useactor;2 3 Importcom.badlogic.gdx.graphics.Texture;4 ImportCom.badlogic.gdx.graphics.g2d.Batch;5 ImportCom.badlogic.gdx.scenes.scene2d.Actor;6 7 /**8 * First Actor class9  * @authorJack (Le Zhi)Ten * @blog dtblog.cn One * @qq 984137183 A  */ -  Public classFirsrtactorextendsactor{ -     PrivateTexture Texture; the      PublicFirsrtactor () { -          This. Init (); -     } -     Private voidinit () { +Texture=NewTexture ("Badlogic.jpg"); -     } + @Override A      Public voidDraw (Batch batch,floatParentalpha) { atBatch.draw (texture,0,0); -     } -      -}
1  PackageCom.mygdx.useactor;2 3 ImportCom.badlogic.gdx.ApplicationAdapter;4 ImportCom.badlogic.gdx.Gdx;5 Importcom.badlogic.gdx.graphics.GL20;6 ImportCom.badlogic.gdx.graphics.g2d.SpriteBatch;7 /**8 * Game main class, using actors9  * @authorJack (Le Zhi)Ten * @blog dtblog.cn One * @qq 984137183 A  */ -  Public classMaingameextendsApplicationadapter { -      Publicspritebatch Batch; the      Publicfirsrtactor actor; - @Override -      Public voidCreate () { -Batch=NewSpriteBatch (); +Actor=Newfirsrtactor (); -     } +  A @Override at      Public voidrender () { -         //set the background color to white -Gdx.gl.glClearColor (1, 1, 1, 1); -         //Clear Screen - Gdx.gl.glClear (gl20.gl_color_buffer_bit); - Batch.begin (); inActor.draw (Batch, 0.3f); - batch.end (); to     } +  -}

The original is written by Bo Master Le Zhi Editor, the copyright belongs to the Bo owner. The original address http://www.dtblog.cn/1149.html reprint please specify the source!

"Open source Java Game Framework Libgdx theme" -11-Core Library-Actor class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.