mirror of https://github.com/axmolengine/axmol.git
More unsinged int -> int in some places where it could be difficult to find underflow bugs. And some warnings fix.
This commit is contained in:
parent
c154d66bf0
commit
b58d18e20a
|
@ -113,7 +113,7 @@ bool LabelAtlas::initWithString(const char *theString, const char *fntFile)
|
|||
//CCLabelAtlas - Atlas generation
|
||||
void LabelAtlas::updateAtlasValues()
|
||||
{
|
||||
unsigned int n = _string.length();
|
||||
int n = _string.length();
|
||||
|
||||
const unsigned char *s = (unsigned char*)_string.c_str();
|
||||
|
||||
|
@ -130,7 +130,7 @@ void LabelAtlas::updateAtlasValues()
|
|||
|
||||
CCASSERT( n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
|
||||
V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads();
|
||||
for(unsigned int i = 0; i < n; i++) {
|
||||
for(int i = 0; i < n; i++) {
|
||||
|
||||
unsigned char a = s[i] - _mapStartChar;
|
||||
float row = (float) (a % _itemsPerRow);
|
||||
|
@ -178,7 +178,7 @@ void LabelAtlas::updateAtlasValues()
|
|||
}
|
||||
if (n > 0 ){
|
||||
_textureAtlas->setDirty(true);
|
||||
unsigned int totalQuads = _textureAtlas->getTotalQuads();
|
||||
int totalQuads = _textureAtlas->getTotalQuads();
|
||||
if (n > totalQuads) {
|
||||
_textureAtlas->increaseTotalQuadsWith(n - totalQuads);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void LabelAtlas::updateAtlasValues()
|
|||
//CCLabelAtlas - LabelProtocol
|
||||
void LabelAtlas::setString(const char *label)
|
||||
{
|
||||
unsigned int len = strlen(label);
|
||||
int len = strlen(label);
|
||||
if (len > _textureAtlas->getTotalQuads())
|
||||
{
|
||||
_textureAtlas->resizeCapacity(len);
|
||||
|
|
|
@ -443,7 +443,7 @@ void ParticleBatchNode::disableParticle(unsigned int particleIndex)
|
|||
// ParticleBatchNode - add / remove / reorder helper methods
|
||||
|
||||
// add child helper
|
||||
void ParticleBatchNode::insertChild(ParticleSystem* pSystem, unsigned int index)
|
||||
void ParticleBatchNode::insertChild(ParticleSystem* pSystem, int index)
|
||||
{
|
||||
pSystem->setAtlasIndex(index);
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
bool initWithFile(const char* fileImage, unsigned int capacity);
|
||||
|
||||
/** Inserts a child into the ParticleBatchNode */
|
||||
void insertChild(ParticleSystem* pSystem, unsigned int index);
|
||||
void insertChild(ParticleSystem* pSystem, int index);
|
||||
|
||||
void removeChildAtIndex(unsigned int index, bool doCleanup);
|
||||
void removeAllChildrenWithCleanup(bool doCleanup);
|
||||
|
|
|
@ -699,7 +699,7 @@ void SpriteBatchNode::setTexture(Texture2D *texture)
|
|||
// SpriteSheet Extension
|
||||
//implementation SpriteSheet (TMXTiledMapExtension)
|
||||
|
||||
void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, unsigned int index)
|
||||
void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, int index)
|
||||
{
|
||||
CCASSERT( sprite != NULL, "Argument must be non-NULL");
|
||||
CCASSERT( dynamic_cast<Sprite*>(sprite), "CCSpriteBatchNode only supports Sprites as children");
|
||||
|
@ -724,7 +724,7 @@ void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, unsigned int index)
|
|||
sprite->updateTransform();
|
||||
}
|
||||
|
||||
void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, unsigned int index)
|
||||
void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, int index)
|
||||
{
|
||||
CCASSERT(sprite != NULL, "Argument must be non-nil");
|
||||
CCASSERT(dynamic_cast<Sprite*>(sprite) != NULL, "CCSpriteBatchNode only supports Sprites as children");
|
||||
|
@ -747,7 +747,7 @@ void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, unsigned int index)
|
|||
sprite->updateTransform();
|
||||
}
|
||||
|
||||
SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, unsigned int z, int aTag)
|
||||
SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int aTag)
|
||||
{
|
||||
CCASSERT( child != NULL, "Argument must be non-NULL");
|
||||
CCASSERT( dynamic_cast<Sprite*>(child), "CCSpriteBatchNode only supports Sprites as children");
|
||||
|
|
|
@ -154,16 +154,16 @@ protected:
|
|||
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.
|
||||
For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont)
|
||||
*/
|
||||
void insertQuadFromSprite(Sprite *sprite, unsigned int index);
|
||||
void insertQuadFromSprite(Sprite *sprite, int index);
|
||||
/** Updates a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.
|
||||
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.
|
||||
For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont)
|
||||
*/
|
||||
void updateQuadFromSprite(Sprite *sprite, unsigned int index);
|
||||
void updateQuadFromSprite(Sprite *sprite, int index);
|
||||
/* This is the opposite of "addQuadFromSprite.
|
||||
It add the sprite to the children and descendants array, but it doesn't update add it to the texture atlas
|
||||
*/
|
||||
SpriteBatchNode * addSpriteWithoutQuad(Sprite*child, unsigned int z, int aTag);
|
||||
SpriteBatchNode * addSpriteWithoutQuad(Sprite*child, int z, int aTag);
|
||||
|
||||
private:
|
||||
void updateAtlasIndex(Sprite* sprite, int* curIndex);
|
||||
|
|
|
@ -170,7 +170,7 @@ Color3B TileMapAtlas::getTileAt(const Point& position) const
|
|||
return value;
|
||||
}
|
||||
|
||||
void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, unsigned int index)
|
||||
void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, int index)
|
||||
{
|
||||
CCASSERT( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index");
|
||||
|
||||
|
@ -228,7 +228,7 @@ void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, un
|
|||
quad->bl.colors = color;
|
||||
|
||||
_textureAtlas->setDirty(true);
|
||||
unsigned int totalQuads = _textureAtlas->getTotalQuads();
|
||||
int totalQuads = _textureAtlas->getTotalQuads();
|
||||
if (index + 1 > totalQuads) {
|
||||
_textureAtlas->increaseTotalQuadsWith(index + 1 - totalQuads);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
private:
|
||||
void loadTGAfile(const char *file);
|
||||
void calculateItemsToRender();
|
||||
void updateAtlasValueAt(const Point& pos, const Color3B& value, unsigned int index);
|
||||
void updateAtlasValueAt(const Point& pos, const Color3B& value, int index);
|
||||
void updateAtlasValues();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -175,7 +175,7 @@ void Bone::update(float delta)
|
|||
_worldTransform.tx = _tweenData->x;
|
||||
_worldTransform.ty = _tweenData->y;
|
||||
|
||||
_worldTransform = AffineTransformConcat(nodeToParentTransform(), _worldTransform);
|
||||
_worldTransform = AffineTransformConcat(getNodeToParentTransform(), _worldTransform);
|
||||
|
||||
if(_parent)
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ void DisplayFactory::updateDisplay(Bone *bone, DecorativeDisplay *decoDisplay, f
|
|||
ColliderDetector *detector = decoDisplay->getColliderDetector();
|
||||
if (detector)
|
||||
{
|
||||
AffineTransform t = AffineTransformConcat(bone->nodeToArmatureTransform(), bone->getArmature()->nodeToWorldTransform());
|
||||
AffineTransform t = AffineTransformConcat(bone->nodeToArmatureTransform(), bone->getArmature()->getNodeToWorldTransform());
|
||||
detector->updateTransform(t);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ static Rect getRect(Node * pNode)
|
|||
{
|
||||
Size contentSize = pNode->getContentSize();
|
||||
Rect rect = Rect(0, 0, contentSize.width, contentSize.height);
|
||||
return RectApplyAffineTransform(rect, pNode->nodeToWorldTransform());
|
||||
return RectApplyAffineTransform(rect, pNode->getNodeToWorldTransform());
|
||||
}
|
||||
|
||||
void EditBox::keyboardWillShow(IMEKeyboardNotificationInfo& info)
|
||||
|
|
|
@ -90,7 +90,7 @@ private:
|
|||
CC_UNUSED_PARAM(pEvent);
|
||||
const bool hits = touchHits(pTouch);
|
||||
if (hits)
|
||||
scaleButtonTo(0.9);
|
||||
scaleButtonTo(0.9f);
|
||||
return hits;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ private:
|
|||
|
||||
void scaleButtonTo(float scale)
|
||||
{
|
||||
auto action = ScaleTo::create(0.1, scale);
|
||||
auto action = ScaleTo::create(0.1f, scale);
|
||||
action->setTag(900);
|
||||
stopActionByTag(900);
|
||||
runAction(action);
|
||||
|
@ -252,37 +252,37 @@ void CocosDenshionTest::onExit()
|
|||
void CocosDenshionTest::addButtons()
|
||||
{
|
||||
LabelTTF *lblMusic = LabelTTF::create("Control Music", "Arial", 24);
|
||||
addChildAt(lblMusic, 0.25, 0.9);
|
||||
addChildAt(lblMusic, 0.25f, 0.9f);
|
||||
|
||||
Button *btnPlay = Button::createWithText("play");
|
||||
btnPlay->onTriggered([]() {
|
||||
SimpleAudioEngine::getInstance()->playBackgroundMusic(MUSIC_FILE, true);
|
||||
});
|
||||
addChildAt(btnPlay, 0.1, 0.75);
|
||||
addChildAt(btnPlay, 0.1f, 0.75f);
|
||||
|
||||
Button *btnStop = Button::createWithText("stop");
|
||||
btnStop->onTriggered([]() {
|
||||
SimpleAudioEngine::getInstance()->stopBackgroundMusic();
|
||||
});
|
||||
addChildAt(btnStop, 0.25, 0.75);
|
||||
addChildAt(btnStop, 0.25f, 0.75f);
|
||||
|
||||
Button *btnRewindMusic = Button::createWithText("rewind");
|
||||
btnRewindMusic->onTriggered([]() {
|
||||
SimpleAudioEngine::getInstance()->rewindBackgroundMusic();
|
||||
});
|
||||
addChildAt(btnRewindMusic, 0.4, 0.75);
|
||||
addChildAt(btnRewindMusic, 0.4f, 0.75f);
|
||||
|
||||
Button *btnPause = Button::createWithText("pause");
|
||||
btnPause->onTriggered([]() {
|
||||
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
||||
});
|
||||
addChildAt(btnPause, 0.1, 0.65);
|
||||
addChildAt(btnPause, 0.1f, 0.65f);
|
||||
|
||||
Button *btnResumeMusic = Button::createWithText("resume");
|
||||
btnResumeMusic->onTriggered([]() {
|
||||
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
||||
});
|
||||
addChildAt(btnResumeMusic, 0.25, 0.65);
|
||||
addChildAt(btnResumeMusic, 0.25f, 0.65f);
|
||||
|
||||
Button *btnIsPlayingMusic = Button::createWithText("is playing");
|
||||
btnIsPlayingMusic->onTriggered([]() {
|
||||
|
@ -291,10 +291,10 @@ void CocosDenshionTest::addButtons()
|
|||
else
|
||||
CCLOG("background music is not playing");
|
||||
});
|
||||
addChildAt(btnIsPlayingMusic, 0.4, 0.65);
|
||||
addChildAt(btnIsPlayingMusic, 0.4f, 0.65f);
|
||||
|
||||
LabelTTF *lblSound = LabelTTF::create("Control Effects", "Arial", 24);
|
||||
addChildAt(lblSound, 0.75, 0.9);
|
||||
addChildAt(lblSound, 0.75f, 0.9f);
|
||||
|
||||
Button *btnPlayEffect = Button::createWithText("play");
|
||||
btnPlayEffect->onTriggered([this]() {
|
||||
|
@ -303,7 +303,7 @@ void CocosDenshionTest::addButtons()
|
|||
const float gain = _sliderGain->getValue();
|
||||
_soundId = SimpleAudioEngine::getInstance()->playEffect(EFFECT_FILE, false, pitch, pan, gain);
|
||||
});
|
||||
addChildAt(btnPlayEffect, 0.6, 0.8);
|
||||
addChildAt(btnPlayEffect, 0.6f, 0.8f);
|
||||
|
||||
Button *btnPlayEffectInLoop = Button::createWithText("play in loop");
|
||||
btnPlayEffectInLoop->onTriggered([this]() {
|
||||
|
@ -312,82 +312,82 @@ void CocosDenshionTest::addButtons()
|
|||
const float gain = _sliderGain->getValue();
|
||||
_soundId = SimpleAudioEngine::getInstance()->playEffect(EFFECT_FILE, true, pitch, pan, gain);
|
||||
});
|
||||
addChildAt(btnPlayEffectInLoop, 0.75, 0.8);
|
||||
addChildAt(btnPlayEffectInLoop, 0.75f, 0.8f);
|
||||
|
||||
Button *btnStopEffect = Button::createWithText("stop");
|
||||
btnStopEffect->onTriggered([this]() {
|
||||
SimpleAudioEngine::getInstance()->stopEffect(_soundId);
|
||||
});
|
||||
addChildAt(btnStopEffect, 0.9, 0.8);
|
||||
addChildAt(btnStopEffect, 0.9f, 0.8f);
|
||||
|
||||
Button *btnUnloadEffect = Button::createWithText("unload");
|
||||
btnUnloadEffect->onTriggered([this]() {
|
||||
SimpleAudioEngine::getInstance()->unloadEffect(EFFECT_FILE);
|
||||
});
|
||||
addChildAt(btnUnloadEffect, 0.6, 0.7);
|
||||
addChildAt(btnUnloadEffect, 0.6f, 0.7f);
|
||||
|
||||
Button *btnPauseEffect = Button::createWithText("pause");
|
||||
btnPauseEffect->onTriggered([this]() {
|
||||
SimpleAudioEngine::getInstance()->pauseEffect(_soundId);
|
||||
});
|
||||
addChildAt(btnPauseEffect, 0.75, 0.7);
|
||||
addChildAt(btnPauseEffect, 0.75f, 0.7f);
|
||||
|
||||
Button *btnResumeEffect = Button::createWithText("resume");
|
||||
btnResumeEffect->onTriggered([this]() {
|
||||
SimpleAudioEngine::getInstance()->resumeEffect(_soundId);
|
||||
});
|
||||
addChildAt(btnResumeEffect, 0.9, 0.7);
|
||||
addChildAt(btnResumeEffect, 0.9f, 0.7f);
|
||||
|
||||
Button *btnPauseAll = Button::createWithText("pause all");
|
||||
btnPauseAll->onTriggered([this]() {
|
||||
SimpleAudioEngine::getInstance()->pauseAllEffects();
|
||||
});
|
||||
addChildAt(btnPauseAll, 0.6, 0.6);
|
||||
addChildAt(btnPauseAll, 0.6f, 0.6f);
|
||||
|
||||
Button *btnResumeAll = Button::createWithText("resume all");
|
||||
btnResumeAll->onTriggered([this]() {
|
||||
SimpleAudioEngine::getInstance()->resumeAllEffects();
|
||||
});
|
||||
addChildAt(btnResumeAll, 0.75, 0.6);
|
||||
addChildAt(btnResumeAll, 0.75f, 0.6f);
|
||||
|
||||
Button *btnStopAll = Button::createWithText("stop all");
|
||||
btnStopAll->onTriggered([this]() {
|
||||
SimpleAudioEngine::getInstance()->stopAllEffects();
|
||||
});
|
||||
addChildAt(btnStopAll, 0.9, 0.6);
|
||||
addChildAt(btnStopAll, 0.9f, 0.6f);
|
||||
}
|
||||
|
||||
void CocosDenshionTest::addSliders()
|
||||
{
|
||||
auto lblPitch = LabelTTF::create("Pitch", "Arial", 14);
|
||||
addChildAt(lblPitch, 0.67, 0.4);
|
||||
addChildAt(lblPitch, 0.67f, 0.4f);
|
||||
_sliderPitch = AudioSlider::create(AudioSlider::Horizontal);
|
||||
_sliderPitch->setValue(0.5, 2, 1);
|
||||
addChildAt(_sliderPitch, 0.85, 0.4);
|
||||
addChildAt(_sliderPitch, 0.85f, 0.4f);
|
||||
|
||||
auto lblPan = LabelTTF::create("Pan", "Arial", 14);
|
||||
addChildAt(lblPan, 0.67, 0.3);
|
||||
addChildAt(lblPan, 0.67f, 0.3f);
|
||||
_sliderPan = AudioSlider::create(AudioSlider::Horizontal);
|
||||
_sliderPan->setValue(-1, 1, 0);
|
||||
addChildAt(_sliderPan, 0.85, 0.3);
|
||||
addChildAt(_sliderPan, 0.85f, 0.3f);
|
||||
|
||||
auto lblGain = LabelTTF::create("Gain", "Arial", 14);
|
||||
addChildAt(lblGain, 0.67, 0.2);
|
||||
addChildAt(lblGain, 0.67f, 0.2f);
|
||||
_sliderGain = AudioSlider::create(AudioSlider::Horizontal);
|
||||
_sliderGain->setValue(0, 1, 1);
|
||||
addChildAt(_sliderGain, 0.85, 0.2);
|
||||
addChildAt(_sliderGain, 0.85f, 0.2f);
|
||||
|
||||
auto lblEffectsVolume = LabelTTF::create("Effects Volume", "Arial", 14);
|
||||
addChildAt(lblEffectsVolume, 0.62, 0.5);
|
||||
addChildAt(lblEffectsVolume, 0.62f, 0.5f);
|
||||
_sliderEffectsVolume = AudioSlider::create(AudioSlider::Horizontal);
|
||||
_sliderEffectsVolume->setValue(0, 1, 1);
|
||||
addChildAt(_sliderEffectsVolume, 0.85, 0.5);
|
||||
addChildAt(_sliderEffectsVolume, 0.85f, 0.5f);
|
||||
|
||||
auto lblMusicVolume = LabelTTF::create("Music Volume", "Arial", 14);
|
||||
addChildAt(lblMusicVolume, 0.12, 0.5);
|
||||
addChildAt(lblMusicVolume, 0.12f, 0.5f);
|
||||
_sliderMusicVolume = AudioSlider::create(AudioSlider::Horizontal);
|
||||
_sliderMusicVolume->setValue(0, 1, 1);
|
||||
addChildAt(_sliderMusicVolume, 0.35, 0.5);
|
||||
addChildAt(_sliderMusicVolume, 0.35f, 0.5f);
|
||||
}
|
||||
|
||||
void CocosDenshionTest::addChildAt(Node *node, float percentageX, float percentageY)
|
||||
|
|
|
@ -241,7 +241,7 @@ void TestCSWithoutSkeleton::onEnter()
|
|||
Armature *armature = NULL;
|
||||
armature = Armature::create("TestBone");
|
||||
armature->getAnimation()->playByIndex(0);
|
||||
armature->setAnchorPoint(Point(0.5, -0.1));
|
||||
armature->setAnchorPoint(Point(0.5f, -0.1f));
|
||||
armature->setScale(0.2f);
|
||||
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y-100));
|
||||
addChild(armature);
|
||||
|
|
|
@ -69,7 +69,7 @@ void ProjectileController::update(float delta)
|
|||
static_cast<EnemyController*>(target->getComponent("EnemyController"))->die();
|
||||
}
|
||||
|
||||
bool isDied = targetsToDelete->count();
|
||||
bool isDied = targetsToDelete->count() > 0;
|
||||
|
||||
targetsToDelete->release();
|
||||
|
||||
|
|
Loading…
Reference in New Issue