Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 精灵;在C+中,更改帧不是流动的+;快板5_C++_Allegro_Allegro5 - Fatal编程技术网

C++ 精灵;在C+中,更改帧不是流动的+;快板5

C++ 精灵;在C+中,更改帧不是流动的+;快板5,c++,allegro,allegro5,C++,Allegro,Allegro5,观看视频: 龙的运动不是流动的。就好像所有的帧都在同时改变一样。我做错了什么 shipImage = al_load_bitmap("dragon_stationary.png"); ship.maxFrame = 5; ship.curFrame = 0; ship.frameCount = 0; ship.frameDelay = 50; ship.frameWidth = 180; ship.frameHeight = 126; ship.animationColumns = 5; shi

观看视频: 龙的运动不是流动的。就好像所有的帧都在同时改变一样。我做错了什么

shipImage = al_load_bitmap("dragon_stationary.png");
ship.maxFrame = 5;
ship.curFrame = 0;
ship.frameCount = 0;
ship.frameDelay = 50;
ship.frameWidth = 180;
ship.frameHeight = 126;
ship.animationColumns = 5;
ship.animationDirection = 1;
//this occurs every 1/60 of a second
void drawShip(SpaceShip &ship, ALLEGRO_BITMAP *flyingShip) {
    if (++ship.frameCount >= ship.frameDelay) {
        if (++ship.curFrame >= ship.maxFrame) {
            ship.curFrame = 0;
            ship.frameCount = 0;
        }
    }

    al_draw_bitmap_region(ship.image, ship.curFrame * ship.frameWidth, 0, ship.frameWidth, ship.frameHeight, ship.x, ship.y, 0);

这是精灵:

尝试绘制各种值的情况:

|帧计数| curFrame|

|-------------------|

|0 | 0|

|1 | 0|

|2 | 0|

|…||

|49 | 0|

|50 | 1|

|51 | 2|

|52 | 3|

|54 | 4|

|55 | 5|

|56 | 0|

|0 | 0|


请注意,当
frameCount
达到50时,它将按顺序在所有帧中爆炸,然后仅在动画完成后重置。您需要在每次到达
frameDelay

时重置
frameCount
对格式感到抱歉,谢谢!另外,您能告诉我如何将位图数组传递给函数吗?ALLEGRO_位图*shipImage[maxFrameShip];initShip(ship,shipImage[maxFrameShip]);void initShip(SpaceShip&ship,ALLEGRO_BITMAP*image){ship.image[0]=image[0];}这是我现在的方式,它不起作用“表达式必须是指向完整对象类型的指针”正确的方式是什么?搜索该错误,如果找不到答案,请打开一个新问题