Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. +(id) scene
  2. {
  3.     // 'scene' is an autorelease object.
  4.     CCScene * scene = [CCScene node];
  5.    
  6.     // 'layer' is an autorelease object.
  7.     HelloWorld * layer = [HelloWorld node];
  8.    
  9.     // add layer as a child to scene
  10.     [scene addChild: layer];
  11.    
  12.     // return the scene
  13.     return scene;
  14. }
  15.  
  16. // - - -
  17.  
  18. // on "init" you need to initialize your instance
  19. -(id) init
  20. {
  21.     if( (self=[super init] ))
  22.     {
  23.         CCLayerColor* colorLayer = [CCLayerColor layerWithColor: ccc4(0, 167, 167, 67)];
  24.         colorLayer.anchorPoint = ccp (.5, .5); // << makes no diff
  25.         colorLayer.position = ccp(.0, .0);
  26.         [self addChild:colorLayer z: -1];
  27.  
  28.        
  29.         Wheel * wheel = [ [ [Wheel alloc] init] autorelease];
  30.        
  31.         [wheel setupWithMagnets: 3];
  32.    
  33.         // takes orientation into account
  34.         CGSize winSize = [[CCDirector sharedDirector] winSizeInPixels];
  35.         printf("%f, %f\n", (float) winSize.width, (float) winSize.height);
  36.        
  37.         wheel.position =  ccp ( winSize.width / 2 - 1, winSize.height / 2 - 1 );
  38.         printf("%f, %f\n", (float) wheel.position.x, (float) wheel.position.y);
  39.        
  40.        
  41.         [self addChild: wheel];
  42.        
  43.         // - - -
  44.        
  45.     }
  46.     return self;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement