类功能在main中不起作用 - SDL

时间:2014-05-08 18:42:32

标签: function class sdl main simulator

我正在尝试制作一种弹跳球模拟器。我有单独的球类,但我有一个问题。如果我在main中调用(例如)Ball类函数myBall.show(),则球不会显示。但是,如果在main中,我会完整地写出函数,而不仅仅是myBall.show(),它可以工作。无论如何要解决这个问题,它也适用于其他功能。

Main.cpp的

// Ball Simulator.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"

#include "Globals(BallSim).h"
#include "Ball.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{


Ball myBall;//ball that will be used for the program

while (quit == false)//game loop, while user hasnt quit
{
    while (SDL_PollEvent(&event)) //while there is an event to handle
    {
        if (event.type == SDL_QUIT)
        {
            quit = true;
            break;
        }

    }

    //show the ball
    myBall.show();//THIS DOESNT WORK, EVEN THOUGH LINE BELOW IS SAME
    //SDL_BlitSurface(BallSurface, NULL, ScreenSurface, &posBall);//THIS WORKS

    //move the ball
    myBall.move();//THIS DOESNT WORK
            SDL_BlitSurface(Ball, NULL, ScreenSurface, &posBall); //THIS WORKS


    //update the window
    SDL_UpdateWindowSurface(Window);

}


return 0;
}

0 个答案:

没有答案