I have a really simple game that, for now, uses CCMotionStreak to show a streak when I touch is moving.
I added a single layer to the scene and add the CCMotitionStreak to that layer. As the touch moves, the streak displays. This works perfect.
However, as soon as I add a background image, the streak no longer shows. The image is added before the layer so that shouldn't be an issue.
If I remove the background image, the streak displays fine. I also tried moving the sprite so it only covers part of the screen and I can see the streaks around the sprite, it just doesn't draw over it.
I also tried setting the ZOrder = 1000 for the motion streak as well without luck.
public override void OnEnter()
{
base.OnEnter();
var backgroundLayer = new CCLayer();
layer = new CCLayer();
AddChild(backgroundLayer);
AddChild(layer);
layer.AddEventListener(new CCEventListenerTouchAllAtOnce { OnTouchesBegan = OnTouchesBegan,
OnTouchesEnded = OnTouchesEnd,
OnTouchesMoved = OnTouchesMoved});
background = new CCSprite("background.png")
{
AnchorPoint = CCPoint.AnchorMiddle,
Position = layer.BoundingBox.Center
};
backgroundLayer.AddChild(background);
}
private void CreateMotionStreak()
{
motionStreakNode = new CCMotionStreak(.8f, .1f, 30, CCColor3B.White, "streak.png")
{
AnchorPoint = CCPoint.AnchorMiddle
};
layer.AddChild(motionStreakNode);
}
private void OnTouchesMoved(List<CCTouch> touches, CCEvent arg2)
{
if (touches.Count > 0 && motionStreakNode != null)
motionStreakNode.Position = touches[0].Location;
}
private void OnTouchesEnd(List<CCTouch> touches, CCEvent arg2)
{
if (touches.Count > 0)
{
motionStreakNode.RemoveFromParent();
}
}
void OnTouchesBegan(List<CCTouch> touches, CCEvent touchEvent)
{
if (touches.Count > 0)
{
CreateMotionStreak();
motionStreakNode.Position = touches[0].Location;
}
}