Skip to content

Commit 03a4ddf

Browse files
Mee-guminggo
authored andcommitted
fix warning (#20146)
* fix warning fix warning * remove integer type constructor for Vec2
1 parent 18165ad commit 03a4ddf

File tree

70 files changed

+1001
-1001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1001
-1001
lines changed

cocos/2d/CCActionTiledGrid.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ void TurnOffTiles::update(float time)
623623
for (unsigned int i = 0; i < _tilesCount; i++ )
624624
{
625625
t = _tilesOrder[i];
626-
Vec2 tilePos( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
626+
Vec2 tilePos((t /_gridSize.height), (float)(t % (int)_gridSize.height));
627627

628628
if ( i < l )
629629
{
@@ -795,9 +795,9 @@ void SplitRows::startWithTarget(Node *target)
795795

796796
void SplitRows::update(float time)
797797
{
798-
for (unsigned int j = 0; j < _gridSize.height; ++j)
798+
for (int j = 0; j < _gridSize.height; ++j)
799799
{
800-
Quad3 coords = getOriginalTile(Vec2(0, j));
800+
Quad3 coords = getOriginalTile(Vec2(0.0f, (float)j));
801801
float direction = 1;
802802

803803
if ( (j % 2 ) == 0 )
@@ -810,7 +810,7 @@ void SplitRows::update(float time)
810810
coords.tl.x += direction * _winSize.width * time;
811811
coords.tr.x += direction * _winSize.width * time;
812812

813-
setTile(Vec2(0, j), coords);
813+
setTile(Vec2(0.0f, (float)j), coords);
814814
}
815815
}
816816

@@ -852,7 +852,7 @@ void SplitCols::update(float time)
852852
{
853853
for (unsigned int i = 0; i < _gridSize.width; ++i)
854854
{
855-
Quad3 coords = getOriginalTile(Vec2(i, 0));
855+
Quad3 coords = getOriginalTile(Vec2((float)i, 0.0f));
856856
float direction = 1;
857857

858858
if ( (i % 2 ) == 0 )
@@ -865,7 +865,7 @@ void SplitCols::update(float time)
865865
coords.tl.y += direction * _winSize.height * time;
866866
coords.tr.y += direction * _winSize.height * time;
867867

868-
setTile(Vec2(i, 0), coords);
868+
setTile(Vec2((float)i, 0.0f), coords);
869869
}
870870
}
871871

cocos/2d/CCAutoPolygon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ unsigned int AutoPolygon::getSquareValue(unsigned int x, unsigned int y, const R
249249
//NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel
250250
auto fixedRect = Rect(rect.origin, rect.size-Size(2,2));
251251

252-
Vec2 tl = Vec2(x-1, y-1);
252+
Vec2 tl((float)x-1, (float)y-1);
253253
sv += (fixedRect.containsPoint(tl) && getAlphaByPos(tl) > threshold)? 1 : 0;
254-
Vec2 tr = Vec2(x, y-1);
254+
Vec2 tr((float)x, (float)y-1);
255255
sv += (fixedRect.containsPoint(tr) && getAlphaByPos(tr) > threshold)? 2 : 0;
256-
Vec2 bl = Vec2(x-1, y);
256+
Vec2 bl((float)x-1, (float)y);
257257
sv += (fixedRect.containsPoint(bl) && getAlphaByPos(bl) > threshold)? 4 : 0;
258-
Vec2 br = Vec2(x, y);
258+
Vec2 br((float)x, (float)y);
259259
sv += (fixedRect.containsPoint(br) && getAlphaByPos(br) > threshold)? 8 : 0;
260260
CCASSERT(sv != 0 && sv != 15, "square value should not be 0, or 15");
261261
return sv;

cocos/2d/CCLabel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ void Label::updateContent()
15681568
// FIXME: system fonts don't report the height of the font correctly. only the size of the texture, which is POT
15691569
y += spriteSize.height / 2;
15701570
// FIXME: Might not work with different vertical alignments
1571-
_underlineNode->drawLine(Vec2(0,y), Vec2(spriteSize.width,y), Color4F(_textSprite->getDisplayedColor()));
1571+
_underlineNode->drawLine(Vec2(0.0f,y), Vec2(spriteSize.width,y), Color4F(_textSprite->getDisplayedColor()));
15721572
}
15731573
}
15741574

@@ -1581,9 +1581,9 @@ void Label::updateContent()
15811581
Vec2 vertices[4] =
15821582
{
15831583
Vec2::ZERO,
1584-
Vec2(_contentSize.width, 0),
1584+
Vec2(_contentSize.width, 0.0f),
15851585
Vec2(_contentSize.width, _contentSize.height),
1586-
Vec2(0, _contentSize.height)
1586+
Vec2(0.0f, _contentSize.height)
15871587
};
15881588
_debugDrawNode->drawPoly(vertices, 4, true, Color4F::WHITE);
15891589
#endif

cocos/2d/CCLabelAtlas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
264264
Vec2::ZERO,
265265
Vec2(size.width, 0),
266266
Vec2(size.width, size.height),
267-
Vec2(0, size.height)
267+
Vec2(0.0f, size.height)
268268
};
269269
_debugDrawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0));
270270
}

cocos/2d/CCLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ class CC_DLL LayerGradient : public LayerColor
427427
Color3B _endColor = Color3B::BLACK;
428428
uint8_t _startOpacity = 255;
429429
uint8_t _endOpacity = 255;
430-
Vec2 _alongVector = {0, -1};
430+
Vec2 _alongVector = {0.0f, -1.0f};
431431
bool _compressedInterpolation = true;
432432
};
433433

cocos/2d/CCParticleExamples.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles)
10761076
// emitter position
10771077
Size winSize = Director::getInstance()->getWinSize();
10781078
this->setPosition(winSize.width/2, winSize.height + 10);
1079-
setPosVar(Vec2(winSize.width/2, 0));
1079+
setPosVar(Vec2(winSize.width/2, 0.0f));
10801080

10811081
// angle
10821082
_angle = -90;
@@ -1188,7 +1188,7 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles)
11881188
// emitter position
11891189
Size winSize = Director::getInstance()->getWinSize();
11901190
this->setPosition(winSize.width/2, winSize.height);
1191-
setPosVar(Vec2(winSize.width/2, 0));
1191+
setPosVar(Vec2(winSize.width/2, 0.0f));
11921192

11931193
// life of particles
11941194
_life = 4.5f;

cocos/2d/CCTMXXMLParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
416416
{
417417
TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back();
418418

419-
double tileOffsetX = attributeDict["x"].asDouble();
419+
float tileOffsetX = attributeDict["x"].asFloat();
420420

421-
double tileOffsetY = attributeDict["y"].asDouble();
421+
float tileOffsetY = attributeDict["y"].asFloat();
422422

423423
tileset->_tileOffset = Vec2(tileOffsetX, tileOffsetY);
424424

cocos/2d/CCTransition.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void TransitionJumpZoom::onEnter()
360360
_inScene->setAnchorPoint(Vec2(0.5f, 0.5f));
361361
_outScene->setAnchorPoint(Vec2(0.5f, 0.5f));
362362

363-
ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0), s.width/4, 2);
363+
ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0.0f), s.width/4, 2);
364364
ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f);
365365
ActionInterval *scaleOut = ScaleTo::create(_duration/4, 0.5f);
366366

@@ -425,7 +425,7 @@ void TransitionMoveInL::onEnter()
425425

426426
ActionInterval* TransitionMoveInL::action()
427427
{
428-
return MoveTo::create(_duration, Vec2(0,0));
428+
return MoveTo::create(_duration, Vec2(0.0f,0.0f));
429429
}
430430

431431
ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
@@ -569,13 +569,13 @@ void TransitionSlideInL::sceneOrder()
569569
void TransitionSlideInL:: initScenes()
570570
{
571571
Size s = Director::getInstance()->getWinSize();
572-
_inScene->setPosition(-(s.width-ADJUST_FACTOR),0);
572+
_inScene->setPosition(-(s.width-ADJUST_FACTOR),0.0f);
573573
}
574574

575575
ActionInterval* TransitionSlideInL::action()
576576
{
577577
Size s = Director::getInstance()->getWinSize();
578-
return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0));
578+
return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0.0f));
579579
}
580580

581581
ActionInterval* TransitionSlideInL::easeActionWithAction(ActionInterval* action)
@@ -632,7 +632,7 @@ void TransitionSlideInR::initScenes()
632632
ActionInterval* TransitionSlideInR:: action()
633633
{
634634
Size s = Director::getInstance()->getWinSize();
635-
return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0));
635+
return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0.0f));
636636
}
637637

638638

@@ -673,7 +673,7 @@ void TransitionSlideInT::initScenes()
673673
ActionInterval* TransitionSlideInT::action()
674674
{
675675
Size s = Director::getInstance()->getWinSize();
676-
return MoveBy::create(_duration, Vec2(0,-(s.height-ADJUST_FACTOR)));
676+
return MoveBy::create(_duration, Vec2(0.0f,-(s.height-ADJUST_FACTOR)));
677677
}
678678

679679
//
@@ -713,7 +713,7 @@ void TransitionSlideInB:: initScenes()
713713
ActionInterval* TransitionSlideInB:: action()
714714
{
715715
Size s = Director::getInstance()->getWinSize();
716-
return MoveBy::create(_duration, Vec2(0,s.height-ADJUST_FACTOR));
716+
return MoveBy::create(_duration, Vec2(0.0f,s.height-ADJUST_FACTOR));
717717
}
718718

719719
//

cocos/physics/CCPhysicsShape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class CC_DLL PhysicsShapeCircle : public PhysicsShape
388388
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
389389
* @return An autoreleased PhysicsShapeCircle object pointer.
390390
*/
391-
static PhysicsShapeCircle* create(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2(0, 0));
391+
static PhysicsShapeCircle* create(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2(0.0f, 0.0f));
392392

393393
/**
394394
* Calculate the area of a circle with specified radius.

cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S)
598598
return 0;
599599
}
600600

601-
for (auto i = 0; i < argc; ++i)
601+
for (int i = 0; i < argc; ++i)
602602
{
603603
#if COCOS2D_DEBUG >= 1
604604
if (!tolua_isusertype(tolua_S, i + 2,"cc.MenuItem",0,&tolua_err) )
@@ -2403,7 +2403,7 @@ int tolua_cocos2d_Node_setAnchorPoint(lua_State* tolua_S)
24032403
if (!ok)
24042404
return 0;
24052405

2406-
cobj->setAnchorPoint(cocos2d::Vec2(x,y));
2406+
cobj->setAnchorPoint(cocos2d::Vec2((float)x,(float)y));
24072407
lua_settop(tolua_S, 1);
24082408
return 1;
24092409
}
@@ -7830,10 +7830,10 @@ static int tolua_cocos2d_Mat4_transformVector(lua_State* tolua_S)
78307830
if (!ok)
78317831
return 0;
78327832

7833-
x = (float)tolua_tonumber(tolua_S, 2, 0);
7834-
y = (float)tolua_tonumber(tolua_S, 3, 0);
7835-
z = (float)tolua_tonumber(tolua_S, 4, 0);
7836-
w = (float)tolua_tonumber(tolua_S, 5, 0);
7833+
x = tolua_tonumber(tolua_S, 2, 0);
7834+
y = tolua_tonumber(tolua_S, 3, 0);
7835+
z = tolua_tonumber(tolua_S, 4, 0);
7836+
w = tolua_tonumber(tolua_S, 5, 0);
78377837

78387838
mat.transformVector(x,y,z,w, &dst);
78397839
vec3_to_luaval(tolua_S, dst);
@@ -8832,7 +8832,7 @@ static int tolua_cocos2d_bytearray_floatv(lua_State *L)
88328832
}
88338833
lua_pop(L, 1);
88348834
lua_newtable(L);
8835-
for (size_t idx = 0; idx < arg.size(); idx++)
8835+
for (auto idx = 0; idx < arg.size(); idx++)
88368836
{
88378837
lua_pushnumber(L, arg[idx]);
88388838
lua_rawseti(L, 1, idx + 1);

0 commit comments

Comments
 (0)