CCParallaxNode parallaxRatio(解释) [英] CCParallaxNode parallaxRatio (explanation)

查看:165
本文介绍了CCParallaxNode parallaxRatio(解释)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得愚蠢的问这个问题,但我不能在任何地方找到一个明确的答案(或许多答案),所以我觉得我必须问。有没有人可以解释清楚CCParallaxNode的parallaxRatio是如何工作的?



我已经检查了CCParallaxNode的源,它不解释它。我已经搜索互联网和stackOverflow广泛。我试着做好的老试验和错误。我仍然困惑。

  [parallaxLayer addChild:backgroundEffect_subtleRed z:100 parallaxRatio:ccp(0.5,0.5)positionOffset:backgroundEffect_subtleRed。位置]; 

在这段代码中,我试图添加一个粒子发射器到视差层像您期望视差图层上的对象移动。不幸的是,我根本看不到颗粒。我有这个问题,任何时候我尝试添加任何东西到parallaxNode当我想要移动。我一直在使用CCParallaxNode创建静态UI层,但是不能使用它们为他们建立做什么。



总结:



parallaxRatio需要一个CGPoint。 CGPoint中的浮点数适用于什么?它们是x和y相对于窗口的比率吗?是他们(parallaxLayerMovementInRelationTo,parentNode)?

解决方案
>

引用我自己的cocos2d书:

  [paraNode addChild:para1 z:1 parallaxRatio:CGPointMake f,0)positionOffset:topOffset]; 
[paraNode addChild:para2 z:2 parallaxRatio:CGPointMake(1,0)positionOffset:topOffset];
[paraNode addChild:para3 z:4 parallaxRatio:CGPointMake(2,0)positionOffset:midOffset];
[paraNode addChild:para4 z:3 parallaxRatio:CGPointMake(3,0)positionOffset:downOffset];

CCParallaxNode是像任何其他节点一样创建的,它指定视差比,这是一个CGPoint用作CCParallaxNode的任何移动的乘数。在这种情况下,para1将以速度的一半移动,以正常速度移动para2,以CCParallaxNode的速度的两倍移动para3,因此on



基本上,它的各个图层的移动与整个CCParallaxNode的移动的比例。


I feel stupid asking this question, but I can not find a clear answer anywhere (or much of an answer at all) so I feel I must ask. Is there anyone out there who can explain clearly how the parallaxRatio of CCParallaxNode works?

I have checked the source of CCParallaxNode and it does not explain it at all. I have searched the internet and stackOverflow extensively. I have tried to do good old trial and error. I'm still confused.

[parallaxLayer addChild:backgroundEffect_subtleRed z:100 parallaxRatio:ccp(0.5, 0.5) positionOffset:backgroundEffect_subtleRed.position];

In this piece of code I am trying to add a particle emitter to a parallaxLayer and have it move somewhat like you would expect an object on a parallax layer to move. Unfortunately I do not see the particles at all. I have had this problem anytime I try to add anything to a parallaxNode when I want it to move. I have been using CCParallaxNode to create static UI layers, but have not been able to use them for what they were built to do.

In summary:

parallaxRatio takes a CGPoint. What do the floats in the CGPoint apply to? Are they ratios of x and y in relation to the window? Are they (parallaxLayerMovementInRelationTo, parentNode)? A working piece of example code would be very helpful.

Thank you.

解决方案

To quote from a cocos2d book I own:

[paraNode addChild:para1 z:1 parallaxRatio:CGPointMake(0.5f, 0) positionOffset:topOffset];
    [paraNode addChild:para2 z:2 parallaxRatio:CGPointMake(1, 0) positionOffset:topOffset];
    [paraNode addChild:para3 z:4 parallaxRatio:CGPointMake(2, 0) positionOffset:midOffset];
    [paraNode addChild:para4 z:3 parallaxRatio:CGPointMake(3, 0) positionOffset:downOffset];

"The CCParallaxNode is created like any other node, but its children are added using a special initializer. With it you specify the parallax ratio, which is a CGPoint used as a multiplier for any movement of the CCParallaxNode In this case, para1 would move at half the speed, para2 at the normal speed, para3 at double the speed of the CCParallaxNode, and so on"

So basically, its the ratio that the individual layers are moved in the relation to the movement of the whole CCParallaxNode.

这篇关于CCParallaxNode parallaxRatio(解释)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆