错误:使用类型“ sfVector2f”初始化类型“ unsigned int”时类型不兼容

时间:2019-01-20 12:45:43

标签: c sfml

我需要使用CSFML lib编写游戏,我试图遵循SFML中的指南,但出现错误。

错误:使用类型“ sfVector2f {aka struct}”初始化类型“ unsigned int”时类型不兼容      sfVector2u size = {sfSprite_getScale(sprite)};

#include "include/game_include.h"
int main()
{
sfVideoMode mode = {800, 600, 32};
sfRenderWindow* window;
sfTexture* texture;
sfSprite* sprite;
sfVector2u size = {sfSprite_getScale(sprite));
sfVector2f origin = {};
sfEvent event;
window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, NULL);
if (!window)
    return 1;
texture = sfTexture_createFromFile("img.jpg", NULL);
if (!texture)
    return 1;
sprite = sfSprite_create();
sfSprite_setTexture(sprite, texture, sfTrue);
sfSprite_setOrigin(sprite, origin);
while (sfRenderWindow_isOpen(window))
{
    while (sfRenderWindow_pollEvent(window, &event))
    {
        if (event.type == sfEvtClosed)
            sfRenderWindow_close(window);
    }
    sfRenderWindow_clear(window, sfBlack);
    sfRenderWindow_drawSprite(window, sprite, NULL);
    sfRenderWindow_display(window);
}
sfRenderWindow_destroy(window);
sfSprite_destroy(sprite);
return 0;

}

0 个答案:

没有答案