zoukankan      html  css  js  c++  java
  • cocos2d

          CGSize winSize = [[CCDirector sharedDirector] winSize];

            

            CCParallaxNode * node = [CCParallaxNodenode];

            

            CCSprite * sp1 = [CCSprite spriteWithFile:@"bear1.png"];

            sp1.position = ccp( winSize.width/2,winSize.height/2);

            

            

            CCSprite * sp2 = [CCSprite spriteWithFile:@"bear2.png"];

            sp2.position = ccp( winSize.width/2,winSize.height/2 );

            

            

            CGPoint p1 = CGPointMake(1.0, 1.0);

            CGPoint p2 = CGPointMake(0.5, 0.5);

            

            [node addChild:sp1 z:0 parallaxRatio:p1 positionOffset:CGPointMake(winSize.width/2, winSize.height/2)];

            [node addChild:sp2 z:1 parallaxRatio:p2 positionOffset:CGPointMake(winSize.width/2, winSize.height/2)];

            

            [self addChild:node];

            

            id act1 = [CCMoveTo actionWithDuration:5 position:CGPointMake(winSize.width/2, 0)];

            id act2 = [CCMoveTo actionWithDuration:5 position:CGPointMake(0-winSize.width/2, 0)];

            

            CCSequence * seq = [CCSequence actions:act1,act2, nil];

            CCRepeatForever * rep = [CCRepeatForeveractionWithAction:seq];

            

            [node runAction:rep];

     

    [node addChild:sp1 z:0 parallaxRatio:p1 positionOffset:CGPointMake(winSize.width/2, winSize.height/2)];  中的  positionOffset  是 sp1 相对于node的偏移

    [CCMoveToactionWithDuration:position:CGPointMake(winSize.width/2, 0)];中的 position 是node的位移

  • 相关阅读:
    6.25作业
    博客园第一篇
    532. 数组中的K-diff数对
    echarts
    跨域问题
    数组中第三大的数 leetcode 414
    除自身以外数组的乘积leetcode 238
    xshell工具
    插入、删除和随机查询时间复杂度都为O(1) leetcode 381
    组合总和3 leetcode 216
  • 原文地址:https://www.cnblogs.com/rollrock/p/3587065.html
Copyright © 2011-2022 走看看