CGPath is not detected properly in cocos2d

前端 未结 1 505
夕颜
夕颜 2021-01-21 11:33

Through help and suggestions, I created a path for my sprite so that only the non-transparent parts can be touched. This is the path I came up with:

    path = C         


        
1条回答
  •  佛祖请我去吃肉
    2021-01-21 12:22

    This works only if image size is same. Depending on image size calculate coordinates.

    enter image description here

    CGPathMoveToPoint(path,    NULL,   54, 0 ); //1: 54 = distance from left, 0 = dis fem bottom
    CGPathAddLineToPoint(path, NULL,   28, 34 );
    CGPathAddLineToPoint(path, NULL,   36, 76 );
    CGPathAddLineToPoint(path, NULL,   51, 104 );
    CGPathAddLineToPoint(path, NULL,   46, 147 );
    CGPathAddLineToPoint(path, NULL,   67, 147 );
    CGPathAddLineToPoint(path, NULL,   70, 105 );
    CGPathAddLineToPoint(path, NULL,   56, 66 );
    CGPathAddLineToPoint(path, NULL,   52, 42 );
    CGPathAddLineToPoint(path, NULL,   67, 20 );
    CGPathAddLineToPoint(path, NULL,   92, 0 );
    CGPathCloseSubpath(path);
    

    0 讨论(0)
提交回复
热议问题