Is there any wrong testcpp code for Cocos2d-X?

I downloaded Cocos2d-X and compiled testcpp. But there is something wrong with this, I discovered it and found that there is something wrong in the following code.

debugForNormalSprite->drawPoints(positions, 4, 8, Color4F{0.0,1.0,1.0,1.0});

      

after checking the definition of the drawPoints function. I change the parentheses to parentheses and it works. Is the original code wrong, or is my compiler only wrong? I think the last parameter is just a temporary object to pass the value and am I right? Thanks in advance.

+3


source to share


1 answer


What you see is called uniform initialization, which was added in the C ++ 11 standard. Basically, it's just another way to call a constructor, so

Color4F{0.0,1 .0,1.0,1.0}

      

equivalent to



Color4F(0.0,1.0,1.0,1.0)

      

Here you can see how it works with a simple example: ideone.com/heJJuI

As far as your compilation issue is concerned, this is probably caused by an old compiler that doesn't support uniform initialization. You can try compiling this example from Ideone to figure it out (just remember to compile it with C ++ 11/14 support).

+2


source







All Articles