Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * The MIT License (MIT)
   *
   * Copyright (c) 2014 Christian Gärtner
   *
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  * copies of the Software, and to permit persons to whom the Software is
  * furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in all
  * copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
 
 package org.achtern.AchternEngine.core.scenegraph.entity;
 
 import lombok.Data;

A helper class to create an Entity easily. Implements all methods in order to override only "needed" methods and handels the following: - Storing the parent node - Storing the coreengine - Storing a name (and setting it)
 
 public abstract class QuickEntity implements EntityEngineHolder<CoreEngine> {
 
     public static final String NAME_UNTITLED_ENTITY = "Untitled Entity";
 
     protected Node parent;
     protected CoreEngine engine;
     protected String name;
 
     protected boolean destroy = false;

    
Create an "Untitled Entity"
 
     public QuickEntity() {
         this();
     }

    
Create a entity with a specifc name

Parameters:
name The name
 
     public QuickEntity(String name) {
         setName(name);
     }

    
 
     @Override
     public void update(float delta) {
 
     }

    
 
     @Override
     public void render(RenderEngine renderEngine) {
 
     }

    
Sets the parent to null.

 
     @Override
     public void removed() {
         this. = null;
     }

    

See also:
Entity.attached() ()
 
     @Override
     public void attached() {
     }

    
Marks this Entity to be no longer needed. This is just a hint for the various engines operating with this Entity. The org.achtern.AchternEngine.core.rendering.RenderEngine for example could decide to delete the resources for a given Entity from the graphics card's memory, etc.
    @Override
    public void destroy() {
        this.destroy(true);
    }

    
Set whether or not the resources assoc. with this Entity can be destroyed.

Parameters:
shouldbeDestroyed whether or not to destroy this Entity
See also:
destroy()
    @Override
    public void destroy(boolean shouldbeDestroyed) {
        this. = shouldbeDestroyed;
    }

    
If true, the Entity is no longer needed.

Returns:
whether or not to destroy this Entity
See also:
destroy()
    @Override
    public boolean shouldBeDestroyed() {
        return this.;
    }

    
Returns a Node containing this Entity. The Name should equal the name of this Entity.

Returns:
Node with this Entity
    @Override
    public Node boxed() {
        String name = this.getName();
        if (name == null || name.equals()) {
            name = this.getClass().getSimpleName();
        }
        return new Node(name).add(this);
    }


    
    @Override
    public Transform getTransform() {
        return this..getTransform();
    }
New to GrepCode? Check out our FAQ X