Home | History | Annotate | Download | only in replicaisland
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.replica.replicaisland;
     18 
     19 /**
     20  * DrawableObject is the base object interface for objects that can be rendered to the screen.
     21  * Note that objects derived from DrawableObject are passed between threads, and that care must be
     22  * taken when modifying drawable parameters to avoid side-effects (for example, the DrawableFactory
     23  * class can be used to generate fire-and-forget drawables).
     24  */
     25 public abstract class DrawableObject extends AllocationGuard {
     26     private float mPriority;
     27     private ObjectPool mParentPool;
     28 
     29     public abstract void draw(float x, float y, float scaleX, float scaleY);
     30 
     31     public DrawableObject() {
     32         super();
     33     }
     34 
     35     public void setPriority(float f) {
     36         mPriority = f;
     37     }
     38 
     39     public float getPriority() {
     40         return mPriority;
     41     }
     42 
     43     public void setParentPool(ObjectPool pool) {
     44         mParentPool = pool;
     45     }
     46 
     47     public ObjectPool getParentPool() {
     48         return mParentPool;
     49     }
     50 
     51     // Override to allow drawables to be sorted by texture.
     52     public Texture getTexture() {
     53         return null;
     54     }
     55 
     56     // Function to allow drawables to specify culling rules.
     57     public boolean visibleAtPosition(Vector2 position) {
     58         return true;
     59     }
     60 
     61 }
     62