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 public class FixedAnimationComponent extends GameComponent {
     20     private int mAnimationIndex;
     21 
     22     public FixedAnimationComponent() {
     23         super();
     24         setPhase(ComponentPhases.ANIMATION.ordinal());
     25         reset();
     26     }
     27 
     28     @Override
     29     public void reset() {
     30         mAnimationIndex = 0;
     31     }
     32 
     33     @Override
     34     public void update(float timeDelta, BaseObject parent) {
     35         // We look up the sprite component each frame so that this component can be shared.
     36         GameObject parentObject = (GameObject)parent;
     37         SpriteComponent sprite = parentObject.findByClass(SpriteComponent.class);
     38         if (sprite != null) {
     39             sprite.playAnimation(mAnimationIndex);
     40         }
     41     }
     42 
     43     public void setAnimation(int index) {
     44         mAnimationIndex = index;
     45     }
     46 }
     47