コード例 #1
0
bool ParallaxComponentLayer::Initialize()
{
	RETURN_FALSE_IF_FALSE(BaseCaseLayer::Initialize());

	mMainSprite = NodeFactory::Instance().CreateQuadSprite("test2.png");
	mMainSprite->DockToScreen(DockPoint::MiddleTop);
	mMainSprite->SetAnchorPoint(AnchorPoint::MiddleTop);
	AddChild(mMainSprite);

	mComponent = ComponentFactory::Instance().Create<ParallaxComponent>();
	mMainSprite->AddComponent(mComponent);

	
	FOR_EACH_SIZE(i, mChildCount)
	{
		Sprite* child = NodeFactory::Instance().CreateQuadSprite("test2.png");
		child->SetAnchorPoint(AnchorPoint::MiddleTop);
		child->SetPosition(mMainSprite->Position());
		child->MoveY(-child->Height()*(i+1));
		AddChild(child);
		Point3F ratio = Point3F::One;
		ratio.X = (float)(i + 1) / mChildCount;

		mComponent->EnableParallax(child, ratio, child->Position());
	}
コード例 #2
0
	FOR_EACH_SIZE(i, mChildCount)
	{
		Sprite* child = NodeFactory::Instance().CreateSprite("test2.png");
		child->SetAnchorPoint(AnchorPoint::MiddleTop);
		child->SetPosition(mainSprite->Position());
		child->MoveY(-child->Height()*(i + 1));
		normalLayer->AddChild(child);
		Point3F ratio = Point3F::One;
		ratio.X = (float)(mChildCount-i) / mChildCount;

		mComponent->EnableParallax(child, ratio, child->Position());
	}