-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewController.cpp
56 lines (46 loc) · 1.17 KB
/
ViewController.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// ViewController.cpp
// FinalFourFearsomeFantasy
//
// Created by Kyle Koser on 4/8/14.
// Copyright (c) 2014 Kyle Koser. All rights reserved.
//
#include "ViewController.h"
ViewController::ViewController(SDL_Renderer *ren) {
//save the renderer
renderer = ren;
//SDL_RenderClear(renderer);
top = NULL;
}
//override this for custom transition animation
void ViewController::becomeTop(ViewController *baseVC) {
if (baseVC != NULL) {
base = baseVC;
}
SDL_RenderClear(renderer);
}
//remove the ViewController from the window
//not sure how to implement - talk to casey
void ViewController::dismiss() {
if (base != NULL) {
base->becomeTop(NULL);
}
}
void ViewController::pushViewController(ViewController *vc) {
if (top != NULL) {
top = vc;
}
}
void ViewController::draw(SDL_Event e) {
SDL_RenderClear(renderer);
std::cout<<"Drawing a baseVC!"<<endl;
if (top != NULL) {
top->draw(e);
return;
}
//custom drawing code here
}
ViewController::~ViewController() {
//dont want to destroy the renderer, its used by all VCs for that window
//SDL_DestroyRenderer( renderer );
}