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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
# Include "Main. H" # Include "appdelegate. H" # Include "cceglview. H"Using_ns_cc; Lresult mywndprochook (uint message, wparam, lparam, bool * pprocessed ); // Uncomment below line, open debug Console // # Define use_win32_console
Int apientry _ twinmain (hinstance, Hinstance hprevinstance, Lptstr lpcmdline, Int ncmdshow) { Unreferenced_parameter (hprevinstance ); Unreferenced_parameter (lpcmdline ); # Ifdef use_win32_console Allocconsole (); Freopen ("conin $", "r", stdin ); Freopen ("conout $", "W", stdout ); Freopen ("conout $", "W", stderr ); # Endif // Create the application instance Appdelegate app; Cceglview * eglview = cceglview: Export dopenglview (); Eglview-> setframesize (480,320 ); // Eglview-> setframesize (960,640 ); // Eglview-> setframesize (2048,153 6 ); // Eglview-> setframezoomfactor (0.4f ); Eglview-> setwndproc (mywndprochook); // Add this sentence
Int ret = ccapplication: sharedapplication ()-> Run (); # Ifdef use_win32_console Freeconsole (); # Endif Return ret; } Lresult mywndprochook (uint message, wparam, lparam, bool * pprocessed) { Switch (Message) { Case wm_keydown: Case wm_keyup: { // Set with the coordinates when framesize = designresolutionsize Ccpoint Pt = ccpointzero; Switch (wparam) { Case 'A': // left { PT = CPP (25,255 ); } Break; Case 'D': // right { PT = CPP (95,256 ); } Break; Case 'W': // up { PT = CPP (63,214 ); } Break; Case's ': // down { PT = CPP (62,290 ); } Break; Case 'J': // attack { PT = CPP (367,277 ); } Break; Case 'K': // skip { PT = CPP (445,247 ); } Break; Default: Return 0; } If (getkeystate ('D') & 0x8000) { If (getkeystate ('W') & 0x8000) // upper right corner { PT = CPP (91,227 ); } Else if (getkeystate ('s ') & 0x8000) // bottom right corner { PT = CPP (91,284 ); } } Else if (getkeystate ('A') & 0x8000) { If (getkeystate ('W') & 0x8000) // upper left corner { PT = CPP (36,227 ); } Else if (getkeystate ('s ') & 0x8000) // lower left corner { PT = CPP (36,284 ); } } Cceglview * eglview = cceglview: Export dopenglview (); Ccsize originaldesignresolutionsize = ccsizemake (480,320); // Original Design resolution size Resolutionpolicy eresolutionpolicy = kresolutionfixedwidth; // Resolution Policy Ccsize obdesignresolutionsize = eglview-> getdesignresolutionsize (); Int offsetwidth = obdesignresolutionsize. Width-originaldesignresolutionsize. width; Int offsetheight = obdesignresolutionsize. Height-originaldesignresolutionsize. height; Ccsize obscreensize = eglview-> getframesize (); Int offsetwid2= obscreensize. Width-originaldesignresolutionsize. width; Int offsetheight2 = obscreensize. Height-originaldesignresolutionsize. height; Switch (eresolutionpolicy) { Case kresolutionexactfit: { //... } Break; Case kresolutionnoborder: { //... } Break; Case kresolutionshowall: { PT. x + = offsetwid2/ 2; PT. Y + = offsetheight2/2; } Break; Case kresolutionfixedheight: { //... } Break; Case kresolutionfixedwidth: { PT. Y + = offsetheight; } Break; }
PT. x * = eglview-> getscalex (); PT. y * = eglview-> getscaley (); Int id = wparam; If (Message = wm_keydown) { Eglview-> handletouchesbegin (1, & ID, & pt. X, & pt. y ); } Else { Eglview-> handletouchesend (1, & ID, & pt. X, & pt. y ); } * Pprocessed = true; } Break; } Return 0; } |