public void fadeIn(double duration) { // Fade in the main sprite and blob shadow. SKAction fadeAction = SKAction.fadeIn(duration); setAlpha(0.0); runAction(fadeAction); shadowBlob.setAlpha(0.0); shadowBlob.runAction(fadeAction); }
private void init(CGPoint position) { SKTextureAtlas atlas = SKTextureAtlas.create("Environment"); shadowBlob = SKSpriteNode.create(atlas.getTexture("blobShadow.png")); shadowBlob.setZPosition(-1.0); setPosition(position); health = 100.0; movementSpeed = MOVEMENT_SPEED; animated = true; animationSpeed = 1 / 28.0; configurePhysicsBody(); }
public void update(double interval) { // Shadow always follows our main sprite. shadowBlob.setPosition(getPosition()); if (animated) { resolveRequestedAnimation(); } }
void reset() { // Reset some base states (used when recycling character instances). health = 100; dying = false; attacking = false; animated = true; requestedAnimation = APAAnimationState.Idle; shadowBlob.setAlpha(1.0); }
private void animationHasCompleted(APAAnimationState animationState) { if (dying) { animated = false; shadowBlob.runAction(SKAction.fadeOut(1.5)); } animationDidComplete(animationState); if (attacking) { attacking = false; } activeAnimationKey = null; }
@Override public void removeFromParent() { shadowBlob.removeFromParent(); super.removeFromParent(); }
@Override public void setAlpha(double alpha) { super.setAlpha(alpha); shadowBlob.setAlpha(alpha); }
@Override public void setScale(double scale) { super.setScale(scale); shadowBlob.setScale(scale); }