Base on my first question here which was answered by Theis Egeberg (The solution was explained more by Theis in the comment and worked like magic)I would need to also know the following:
(This might have a simple answer but I will leave it it to Theis or anyone who can figure it out.)
What if I have another object bouncing off the the already moving ball in Y axis witch as a different speed ? how do I change alpha of its shadow on the ball.
To explain it nicer and make it more confusing, lets say we have a ping pong racket moving up and down and a ping pong ball that is bouncing of it. With the formula that Theis has provided before, we now know how to animate the alpha of the ping pong racket (previously the the Ball) on the ground but what about the shadow of the ping pong ball on the racket? how can we change its opacity on the racket? Would it be as simple as using the same formula on both rocket an ball:)? Can it be used as a class and be used multiple time here and there and how would you write and use it in places like update?
Here is the code I have implemented using Theis Egeberg's formula.
- (void)update:(CFTimeInterval)currentTime
{
[self enumerateChildNodesWithName:@"shadowOnTheGround" usingBlock:^(SKNode *node, BOOL *stop) {
SKSpriteNode* racket = (SKSpriteNode*)[self childNodeWithName:@"racket"];
node.position = CGPointMake(60,217);
float racketY = racket.position.y;
float theisFormula = (430.0- recketY)/430;
node.alpha = theisFormula;
//NSLog(@"%f", theisFormula);
}];
}