コード例 #1
0
	void terrestres::animEnemigo(int direccion){
		if(direccion == 1){
			enemigo->setFlippedX(false);
			//enemigo->setTexture("E_BipedoDer.png");
		}else{
			enemigo->setFlippedX(true);
			//enemigo->setTexture("E_Bipedo.png");
		}
	}
コード例 #2
0
ファイル: JsonLoader.cpp プロジェクト: b00yan/avalon
void JsonLoader::applyCommonSettings(b2dJsonImage& def, cocos2d::Sprite& sprite)
{
    sprite.setFlippedX(def.flip);
    sprite.setColor({def.colorTint[0], def.colorTint[1], def.colorTint[2]});
    sprite.setOpacity(def.colorTint[3]);

    auto size = sprite.getContentSize();

    auto heightInPixel = def.scale * box2dContainer.pixelsInMeter;
    auto heightScale = heightInPixel / size.height;

    auto widthInPixel = size.width * heightScale * def.aspectScale;
    auto widthScale = widthInPixel / size.width;

    sprite.setScaleX(widthScale);
    sprite.setScaleY(heightScale);
}