1

I'm trying to do a particle effect where I have a cell nested onto another cell. Think of the basic firework example they have here in the Apple Docs. They've nested Cells into other Cells and they've timed them using the BeginTime parameter. I, however, do not have a "beginTime" parameter for my CAEmittorCell like they do, I have one in the CAEmittorLayer instead... How am I supposed to nest cells and have them execute at different times if the cell does not have a beginTime parameter?

Notice in the apple example code they have a "beginTime" parameter for CAEmitterCell

**CAEmitterCell *firework = [CAEmitterCell emitterCell];**
firework.contents = img;
firework.birthRate = 9999;
firework.scale = 0.6;
firework.velocity = 130;
firework.lifetime = 2;
firework.alphaSpeed = -0.2;
firework.yAcceleration = -80;
**firework.beginTime = 1.5;**
firework.duration = 0.1;
firework.emissionRange = 2 * M_PI;
firework.scaleSpeed = -0.1;
firework.spin = 2;

---- Solved, see replies below ----

I simply called the selector manually like this to get the desired result:

CAEmitterCell cell = new CAEmitterCell();
cell.SetValueForKeyPath (NSNumber.FromFloat(1), (NSString)"beginTime");
LampShade
  • 2,675
  • 5
  • 30
  • 60
  • @poupou Seems like `CAEmitterCell` conforms to the `CAMediaTiming` protocol in ObjC and the binding for it is missing in Xamarin.iOS. Then again `CAMediaTiming` seems to be missing completely!? https://github.com/mono/maccore/blob/master/src/coreanimation.cs#L48 – Krumelur Nov 15 '13 at 19:18
  • Interesting, thanks for finding this. Should I contact Xamarin support on this topic? – LampShade Nov 15 '13 at 19:51

1 Answers1

2

The CAMediaTiming bindings are not really missing. They were folded into CAAnimation (here) and CALayer (here). That's because, before 7.0's [Protocol] support, is was the way to implement protocols.

The issue is that CAMediaTiming is documented to be adopted by only those two types - but CAEmitterCell (and maybe others, I need to check) also conforms to it and right now do not expose the protocol methods.

The quick/immediate workaround is to call the missing selector on the instance. Future versions of Xamarin.iOS will provide them.

poupou
  • 43,413
  • 6
  • 77
  • 174