1. Trang chủ
  2. » Luận Văn - Báo Cáo

Luận văn nghiên cứu engine đa nền tảng cocos2d x và phát triển ứng dụng luyện thi toeic trên thiết bị smart phone

91 503 7

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 91
Dung lượng 1,06 MB

Nội dung

BQ CIAO DVC VA DAO T30 TRUtING D3I HQC THANG LONG KHOA LUAN TOT NGHIEP ctru NGHIEN ENGINE DA NEN TANG COCOS2D-X VA PHAT TRIEN (TNG DUNG LUYEN THI TOEIC TREN THIET Di SMART PHONE Gilo viIn huomg din Sink viten thyc hien Mii sinh vien Clow& ngInh : Ths Le Minh Thin : Wog Thanh Ting : A16321 : Khoa hoe may tinh HA NQI-2014 MVC LVC CHITONG GI& TH1$U DV AN 1.1 Vii net vi smartphone Vift Nam- 1.2 Tim quan tryng ala TOEIC 1.3 Gifri thifn Ong dung Isola thi TOEIC tren smartphone 1.3.1 Giai thieu img dung 1.3.2 Lqi feh ala Ong dung luyen thi TOEIC tren smartphone CHliONG COCOS2D-X ENGINE 2.1 Gibi thifn vi Cocos2d-X 2.1.1 Su den cila Cocos2d-X vi Lich sfr ph& trien 2.1.2 Ti lai dung Cocos2d-X 2.2 KV& tree tong quan vi mai truing lint vile 9 11 14 2.2.1 Co du tit chat thu muc 14 2.2.2 Kien true Cocos2d-X engine 15 2.2.3 Mai truing llm viec 16 2.2.4 MOt s6 lop deg Wog thuong duce sfr dung 19 CHUONG PHAN TECH flu CAU NGHI$P VV 32 3.1 Yin an nghifp vg 32 3.2 Su al User-Case cia ding clang 33 3.3 Anh zu yin au nghiep vg vi chic ning 34 3.4 Die ti chic ning hi thong 34 3.4.1 UC#01: Kiem tra kit nai man 34 3.4.2 UC#02: Deng nh$p silo he thong 35 3.4.3 UC#03: Deng Icy di khan 39 3.4.4 UC#04: !Gem tra phien ban vi cop nh$t du lieu 44 3.4.5 UC#05: To di WM vi ceu hdi tric nghiem 47 3.4.6 UC#06: Luyen tap 50 3.4.7 UC#07: Thi dui 56 CHUONG THAT KE VA MIEN HMI UNG DUNG 63 4.1 Kiin trtic hi thong 63 4.2 Thiit id chi tat chic ning thi thfr .64 4.2.1 Topic 65 4.2.2 MCQ 65 4.2.3 ConfigLoader 68 4.2.4 QuestionItem 69 4.2.5 FullTest 70 4.3 Thiit ki as sfr di lien 71 4.3.1 Met hinh quan he 71 43.2 Danh sigh cic bang vi mel to 72 4.3.3 Cac bang de lieu 72 4.4 Cii dit .75 4.4.1 Lwa chon mei tmong 4.4.2 You ciu au hinh di 75 at he thtmg CHUtING KET LUAN VA DJNH HUNG PHAT TRIEN 5.1 Kit qui dot iliac 77 77 5.2 Dinh hiring phit triin PHV LVC — CODE MOT SO 76 alit NANG CHINO Chic thing kiim tra kit not ming 77 79 79 1.1 Native code 79 1.2 Android code 79 1.3 IOS code 80 Chic ning kiim tra tii tip tin vi ghi vio be nha sir clang HttpRequest —81 Chic Ming to di thi TM lien tham khio 82 86 DANH MVC 18 NH VI, SO DO VA BANG BLEU Bing 2.1: So skit giea Cocos2d-X vi ck engine khic 13 Bing 2.2: Co ciu t6 chet thu muc Cocos2d-X 15 Bing 2.3: Bing inh xa kieu de lieu glita Java vi Native code 19 Bing 3.1: Bing inh xa yell ciu ng,hiep vp vi cher Wing 34 Bing 4.1: M8 ti cic bang co so de lieu 72 Hinh 1.1: Tec dO phit trien thi tru6ng smartphone tai Viet Nam Hinh 1.2: T$' le stt dung smartphone phis theo khu Arc thenh thi vi nong thou tai Viet Nam Hlnh 1.3: TS, I¢ smartphone pit he dieu hanh tai Viet Nam Hinh 1.4: TS, le se httu Smartphone m6i hia tutu tai Viet Nam Binh 2.1: M8 kith phit hien Cocos2d-X Binh 2.2: NOi dung tep tin IDE sau ;chi giii nen 14 Hinh 2.3: Kien tnic Cocos2d-X 15 Hlnh 2.4: Mai truerng lam viec 16 Hinh 2.5: Cic dei brung dugc ke that tfr CCNode 21 Hlnh 2.6: Hlnh inh minh hua "Nine patch" 23 Filth 3.1: Su d6 user-case c ►ia ling dung 33 With 2• Man hinh ding nhap 39 Hlnh 3.3: Ciao dien ding kf 43 HIM 3.4: Giao dien ding kjr vi thong bio 16i 43 Hinh 3.5: Giao dien khoi chay (mg dung 47 Hinh 3.6: Giao dien de hal Bang van bin vi cilu hai tic nghiem sau ley de lieu tfr CSDL 54 Hinh 3.7: Man hinh hien thi dap an sau ngutri deng chcm dip in chinh xic 54 Hinh 3.8: Men hinh hien thi de bai clang am kern hinh anh vi cau hal tic nghiem sau ley de lieu to CSDL 55 Filth 3.9: Min hinh hien thi dap in sau ngutri dung chop dap an bi sai 55 Hinh 3.10: Man hinh sau vio chirc rang thi thu 61 Binh 3.11: Min hinh hien thj dash sich cic cAu hal chic ring thi thfr 61 Hinh 3.12: Min hinh hien thi kit qui thi thfr sau holm thinh bii thi 62 Hinh 4.1: Kiin Mk he thong 63 Binh 4.2: Sa d8 lop chi tiet ch0c Ming thi 64 So d6 3.1: So d61u6ng dog viec "ICiem tra kit n6i mpg" 35 Sa Qe 3.2: Sc d8 lutong tong viec "Bang nh$p" 36 So d6 3.3: Sa d6 trInh to "Ding nh.p" 37 Sa d6 3.4: So d6 Wong ding viec "Ding 10" 40 So d6 3.5: So d6 trinh to "Ding kg" 41 Sa d6 3.6: So Q6 1u6ng Gong viec "ICiem tra phiIn bin vi cop nh$t dit lieu" 45 So d6 3.7: So d6 trinh to "'Clem tra phien bin vi cep nhOt de lieu" 46 So M 3.8: Sa Q6 1u6ng &mg viec "Too de bii vi cfu hdi tric nghiem" 48 Sa d6 3.9: So d6 trinh tir "Tao de bii vi clu hdi tic nghiem" 49 Sc d6 3.10: So d61u6ng cong viec "Tao di bii theo chi di di chop" 51 Sa d6 3.11: So d6 trinh to "Too di be' then chi di di chip" 52 So d6 3.12: So d61u6ng ding viec "Thi the 57 Sa Q8 3.13: Sa d6 trinh to "Thi the 58 Sa dB 4.1: M8 hinh dia lieu quan he 71 L(:11 NoI DAU Ngay nay, dien thoai di dung di fro mkt nhung cong cu lien lye thiet yiu mkt ngubi Ngoii chtk tang lien kw, cling vai str phut trier tins ding nghe, ket nOi man du, dien than di Ong dm thwe bi nhieu img dung gild tri, dinh vl, mua sim, town truc tuyen, vi bj ak img dung hqc tip nhu tir dien, chuong trinh office, luyen thi Su bung n6 ye cit so luqng vi chat luqng ala smartphone (dien thooi di dOng thong minh) mot lin nfta lching (firth vj tri quan tong aim n6 cuOc song Viii rim tic lei (My tai Viet Nam, smartphone di c6 sit gia tang manh me ve mot so Mang Da dang chafing loci vi nhieu =lc gin phi hqp yid nhieu phin khtk kWh Hang loft citc smartphone giti re call Samsung, Nokia, LG duqc bin nil thj tnrimg Viet Nam, lchien viec si him nhing chiec smartphone cang trb nen ph6 bien vide clang Mtn bao gib het Theo khao sit colt Google, s6 ngubi clang smartphone di chiem den 20% din s6 caa Viet Nam thin diem kheo sat qu5+1 niim 2013 Google cong b6 tb nghien aim Minh vi trac twin curt Ngubi tieu clang Viet 2014 Ong ty TNS thvc hien, ty' le sir dung smartphone tang 61 20% len 36% TS, le thip hen t9 le truing binh 49% cult the gill, hay 40% cos Than Lan, 51% Malaysia vi 85% cult Singapore, nhung mirc thug truing cho they smartphone ngiy cang duqc chuOng clang d6i yeti ngubi tieu dung Viet Ng,hien ciru coca Google can cho they 50% s6 ngubi duqc MN se khong bao gib rid khei nha me khong c6 smartphone fay Dien thotti di dung vai nhieu tien ich va ben ngubi clang m9i 18c m9i not Ben canh d6, told Viet Nam, PC va Laptop at.) dO phti khong rung biing dien thati Do vey ma dien thoai di dung di va dang tre phucmg tien d6ng vai tr6 quan trong dbi song cult ngubi Viet Trong se nhttng ngtrbi so hitu smartpone tai Viet Nam, nhanh cheng flip va de tiep thu cong nghe mid, d6, them ngubi tre to 16 - 24 mei s6 hOu smartphone nhiiu nhat, chiem tjr le han 50% Tam d6 at ban tam cho cic nha cung cap dich vu tren smartphone nhim khai thac nhu ciu ctia them Mich hang lira Si Ngoai viec s* clung smartphone de ket noi Internet, tin Mem thong tin tut tuyen, nghe nhac ngubi saY dung ce the hqc top moi Mc moi nai Nim bit duqc biting do, cang c6 nhieu nha cung cap dua img dung hqc tip tren smartphone, ngubi hoc co the chit dOng lam cho qua trinh hoc tip trir nen th6 vj vi lei coon hat Trong so d6, ca9cc Ong dung hoc Tieng Anh rot duqc tra chuOng Tnroc day Ltd Viet Nam, nhieu c8ng ty, doanh nghiep, to thubng sir dung chimg chi tieng Anh phin chia theo cap dO A, B, C (chimg chi ABC) nhu mot tieu chi ngoai net di dua quyet djnh ye tuyen dung, b6 nhiem, sip lip thin sit hay b6 tri nhan vien to ng,hiep tai nu& ngoli Tuy nhien ck nAm lit Iai day, chung chi TOEIC nei len nhu mUt tieu chain phi biin hon di danh gia trinh dO thong thao ding Anh ngutri lao dung Xuit phat tfr thvc ti do, nhieu trubng Dai hoc, Cao ding di dim TOEIC vac) chucmg trinh giang day Nit lva chon WU thi TOEIC di theo dOi sv tiin 130 viec hoc tieng Anh d6i vai sinh vien then thing h9c nAm hgc ho(ic sit dung lam chuin tau ding Anh cho sinh vien tot nghiep Chink vi nhttng 15, de nen viec hoc TOEIC, luyen thi TOEIC va tham dv kt thi TOEIC dung vai fro quan tong viec chuin bj Muth tang kien tittle v6i Watt sinh vien va ngueri di lam Tnrec nhu ciu hoc TOEIC cang gia tang vet veri y twang hoc top hen smartphone, the gia chon di di: "My chmg ting Luyen thi TOEIC hen cac thiit hi smartphone" Sv than!' aping cua di tai mang 1pi cho cling ding meot Ong dung co tinh thvc tiin cao, glop nguai sir dung co them cong eta di hoc tip lien dung NOi dung ctla Idles Won duqc chive chucmg: Chuang 1: Giai thieu ye dv an Chuang 2: Ting quan vi Cocos2d-X Engine Chuang 3: Phan tich yeu ciu bah town Chuang 4: That ki va then ;dui Chuang 5: Kit luin CHUDNG GIOI THICU DV AN 1.1 VII net vi smartphone tai Viet Nam Cac chuyen gia cola Google cho rang smartphone da trey mOt plan Icheong the thieu cuOc song vi hien tai ding dam mOt "cuOc cach mpg smartphone" Theo khao sat cola Google, so ngubi dimg smartphone di chiem den 20% din s6 COB Viet Nam thbi diem Ichio sat, tic quf I nam 2013 Nghien dm cola Google cho they 70% s6 ngubi duqc hOi tra lbi h9 si dung smartphone de truy cop Internet, 50% se kung bao gib reri khOi nhi mi khong ceo smartphone tay Dieu thy cho thay neu cac doanh nghiep hitt cic sir dung smartphone thich mOt phan cot lOi chi& Itrqc cis minh thi sa ket n6i vi tiep cAn duqc vii ngubi tieu ding mei Simon Kahn, Tting giam d6c Marketing Google chau A Thii Binh Ducmg (Chief Marketing Officer, Asia Pacific) cho bi& smartphone di thay d6i hanh vi ngubi tieu dung Theo khao sat cis Google, ceo den 92% ngubi dimg smartphone ce the lim nhieu viec cling lice Tai Dien din nap thi Truyen thong CMO Viet Nam nam 2013, doanh nhan cong nghe Bryan Pelz di khimg djnh, sox djch chuyen cia deri sting xi hOi vio Internet vi Mobile II tat yen Nam 2014, ngubi Viet Nam bit du e6 nhing buoy tien hon cong nghe tS, , le din se sir dung smartphone toi Viet Nam di lesirdungmatpho &gIce.TS tang len Iron 36%, gin gap dei so yea 20% cilia nam 2013, de gi6i tre to 16-24 tu6i chiem hon phan nth (58%), nhOm tu6i trung nien 35-44 tang 14% so v6i nam ngoitili 17% Trong tSr le ding may tinh bin (desktop PC) chi tang gin 5%, (fat 44% din so Una theo bing khao sat, Viet Nam dimg thit tong khu Arc Thing Nam A ve t6c dO dip tilling cong nghe mOi theo thj truing, chi sau Philippines Trong do, 59% ngubi Viet Nam chi ring cong nghe mOi mang den nhieu co hOi cho h9 hon rui ro Nhing so tang throng lac quan den to nhieu yeu t6, d6 chi yeu li thai dO lac quan, thich nghi nhanh vii cong nghe mai vi dO phi rung cola smartphone Ben earth de gia thrInh smartphone new cang re Phan khuc smartphone binh din hien rat da clang, gii 2-3 trieu &gig, um cc hOi cho m9i ngubi, bao gem h9c sinh sinh vier, ser hitu mOt chiec dien thotti thong minh tang mang t4i Viet Nam cG dO phi rOng [dip ngubi ding len inimg de ding a Dien Din Hiep HOi Mobile Marketing toi Viet Nam 2014 ngiy 30 thing 10 nam 2014 di dua nhUng s6 thong k8 An urgng vi smartphone tai Viet Nam Trong do: Viet Nam li thi truing smartphone c6 tec go phat thin I6n thir Chau A vi deng thbi ding la thj truing cry mirc dO ph6 bien smartphone I6n thin khu we Bong Nam A; Hinh 1.1: Mc phat trien thi Irwin smartphone tai Viet Nam Vietnam is the second most populated smartphone market in SA 34.3 tam a alb sae' n e Afikvst Hinh 1.2: 7:9 le sti dung smartphone plan theo khu virc thi vet ?Ong then tai Viet Nam 48.6% smartphone dimg hg dieu hi nh Android vi 19.7% dung hg dieu hanh IOS Hinh 1.3: Ty 1e smartphone phiin he cli& hanh tai Viet Nam O mOi lira tu6i, tS/ I sir dung smartphone co str khac biet Ian Trong cao nhAt la nh6m tu6i tir 15 den 29 tu6i Co 56,5% ngtrai dO Mei 20 — 24 tu6i dang so hftu smartphone Ty 'e se hut Smartphone moi Kra to Viet Nam tad 60.0 50.0 40.0 30.0 20.0 10.0 6.9 0.0 15-19 20-24 25-29 30-34 35-39 40-44 45-49 50-54 Hinh 1.4: TS, le so hail Smartphone o mai hia tudi tai Viet Nam Dan vi: Qua nhcmg s6 va th6ng ke tren day, co the thAy thi traang smartphone tai Viet Nam dang co stir tang truemg an Ming Nh(tng ngutri tre tu6i chiem cao nhat s6 4.3.2 Danh sack Sc bdng viz mo td Lim di s6 dia figiteri dung sau kin thi the! Bang 4.1: Mo to cac bang ca so' chi lieu 4.3.3 Cdc bang dfr lieu 4.3.3.1 Bang Subject a Cali true bang Ten trite fp , I1icu tlir lice s 11ii c (1 11 )1)1 (1) subjectID IMO ) non subjectName Varchar(30) (11111 Khong 6a chinh Tit tang b t nghia cua cac gia tri —subjectlD: Gia tri cda kh6a chinh djnh danh, gia trj duce sinh tit dOng —subjectName: Mo to ten mon hoc ho4c 72 4.3.3.2 Bang Topic a Cau tree bang Kier' dir lieu Ten tritiniv, hie d inh Kluia Chu pliep Nil I I topicID hit( 11) Kheng 6a chinh typelD Int(3) Khong Khea ngoai Content Text ImgUrl Varchar(50) Co SoundUrl Varchar(50) C6 Totalques Int(1) Khong It b.t nghia cac gia tri — topiclD: Gia tcj kh6a chinh dinh danh, gia tri duqc sinh to dOng — typelD: gia tri khea ngoai lay tir bang Type dung de xac (filth the loai cim mon thi — content: china nei dung de bli (nett co) — imgUrl: chim lien ket ten tep tin hinh Anh tren server duqc sir dung de bai — SoundUrl: chin lien ket tai tep tin am tren server duqc sir dung de bai — Totalques: china tong s6 cau hod trac nghiem sir dung chung de bAi 4.3.3.3 Bang Type a Cau tree bang Ten tr116112 Met! dii lieu Chu phut) Al I.I ) 15 c d in h Int(3) subjectlD Int(3) tYPeName Varchar(50) b lir nghla cfic gia tri — typelD: gia tri khea chinh dinh danh, gii tri duqc sinh ttr dOng — subjectID: gia tri khea ngoai lay tir bang Subject &mg de xac dinh mon thi tuong (mg — typeName: dien gal ten the loci img vesi mon hqc 73 4.3.3.4 Bang MCQ a Cau true bang "Fen Kieu dir him ( ho phip questionffl Kli o a Kitting KhiSa c Khong Int(11) Khea ngoai \lac Minh : topicID Int(11) Question Varchar(200) Kheng A Varchar(55) CO Varchar(55) C6 Varchar(55) Topic.topicID Co C Varchar(55) Answer - Int(1) Khong b t nghTa cac gia tri — questionID: Gia tri djnh danh khea chinh, gia tri &roc sink tg dOng — topicID: Gia tri khoa ngoai lay tir bang topicID dimg xac dinh de bai tuong CEng — Question: Chira nOi dung cau hoi tric nghiem — A, B, C, D: Chua nOi dung cau tra Itri —Answer: VOri met s6 de bai, dap an duqc doe nOi dung bai nghe, nen trat ttr dm dap an khong the thay d6i Gia tri bang -1 (mg tied cau h6i dap an kh6ng bj c6 djnh de bai 4.3.3.5 Bang User a Cau true bang Ten 111E0112 Kicu dfi lieu (110 phcp AI 1 Email Datetime 'tic (filth UNIQUE Varchar(50) Khong Joined khira Gia he th6ng Khong 74 b t nghia cat gia tri — userlD: Gia tri djnh danh kh6a chinh, gia tri duqc sinh tu do, ng — email: Ten tai khoan cua ngutri dung Gia tri la nhat va khOng phan biet chic hoa thutmg — password: Mat khau clang nhap cua ngutri dung da duqc ma him bang mang barn MD5 — Joined: Ngay clang ky tai khoan Thtri giand dang ky ducce lay yeti gia tren Server 4.3.3.6 Bang History a a Cutrue bang Ten truong Mica ben ('ho pliep At LL dish Mina Id IMO 1) ►Ong 6a Chinh UserID Int(11) Khong Kb:5a ngoai Score Int(4) Datetime Khong g Itheng Time Tv User.userID Gitt hg tilting / b N nghia cac gia tri — ID: Gia tri djnh danh kh6a chinh, gia tri to dOng tang — UserID: Gia tri kh6a ngoai lay dr bang UserID clUng de xfic djnh user tucmg img — Score: Diem s6 nguta dung sau holm tat bai thi — Time: Th6i diem ngutri dimg hoan tat bai thi Then gian duqc lay theo gia tren Server 4.4 CM d$t 4.4.1 Lyra atm mei truning — Ng8n ngil lap trinh: + Native: C++ + Android : Java + Los: Objective C — Cong cu phat trien lap trinh: + Native: Visual Studio 2012 + Android: Eclipse Indigo Service Release 75 + LOS: Xcode — Android SDK — IOS SDK — Cywin 4.4.2 Yeu du du kink chi a#1 he Mang — Thiel bi sir dung he dieu hanh IOS (phien ban 5.0 ire; len) hoac he dieu hanh Android (phien ban 2.3 ire! len) — Dung lugng 130 niter kha dung t61 thieu: 256Mb — RAM: 256Mb hoac cao han 76 CH1YONG 'CET LU4N VA DJNH HISONG PRAT TRIEN 5.1 Ket qui dat dirge Sau thai gian tier hanh du an, tac gia dA lap trinh tong de tai cua minh vai san pham la img dung hfru ich "Luyen thi TOEIC tren dien thoai di (ging" — chucmg trinh bao gem day di' the phan fir ly thuyet den thuc hanh yen cac phan nOi dung kha chi tiet, eau hei da clang, phong phu Chucmg trinh khong chi giap ngueri sir dung luyen thi TOEIC ma can giop luyen nghe tieng Anh tat ham ten thief bj smartphone — Cu the cac ket qua dat duqc nhu sau: + Xing dung luyen thi co day du cac phan de nguai sir dung hoc tap theo tieu chuin vi eau true bai thi TOEIC + Ngoiti nOi dung luyen thi, img dung co the tao cac bai thi thir theo ding tieu chain bai thi TOEIC Day la diem khac biet caa img dung so yeti cac san pham khk ve luyen thi TOEIC tren smartphone dA duct phat hanh truk de tren thj twang + San phim co dung luqng nhe (-2.5mb) rat phu hqp voti cai dat tren smartphone + San pham c6 du lieu dOng, nhCmg update ve du lieu duqc cap nhat bang viec download ttr server ve may, khong can phai update phie'n ban maxi cua img dung Liu diem la nguai sir dung c6 the cap nhat dft lieu nhanh thong, khong can qua trung gian ben thir 5.2 Dinh hirOng phit then a Hoin thien ang dung Ling dung se co than gian chay thu nghiem nham lay y kien danh gia cua nguai sir dung Tir Lk gia se tang hqp cac Iai va hoan thien img dung Viec chay thir la can thiet, giftp tac gia cai thien ling dung cho dap ung cao nhat cac nhu au Gila nguai sir dung Ben canh de, img dung can hoan thien ve mat du lieu de cung cap cho nguai dimg mOt chucmg trinh luyen thi co nOi dung phong phi! nhat Do vay, tee gia se chit y dua cac bin cap nhat du lieu phi' hqp vai nhCmg thay doi nOi dung dm bai thi b Da dang hea san pham Thanh citing Gila ling dung la ea so de tic gia tiep tuc cac an ve cac chuong trinh hoc tap, luyen thi tic nghiem tren smartphone Ling dung luyen thi TOEIC la nen tang ca 77 ban, tir d6 tic gia co the ma rang hem va mo hinh va thiet ke cac san pham incti vii tinh nang tucmg ty Sin pham dip img you eau cac mon hoc c6 nOi dung thi frac nghiem Vi du: Luyen thi dai hoc cac mon thi trac nghiem; cac phan thi tic nghiem cia chuong trinh TOEFL hose IELTS c Tang tinh bao mat du lieu D8 lieu c6 the cap nhat bang viec download tir server a may se gay rui ro ve that thoat dit lieu, d6 da lieu se de" ding bi chap danh cap Vi vay sin pham ducic bao ye, tic gia can tinh den phuong in ma hoa dit lieu dam bao bio mat dir lieu a Ben canh 46, de tang them tinh bao mat, an tinh den bao mat dft lieu i khau nhap du lieu len he thong Vi vay can thiet c6 chuong trinh try nha cung cap nhap der lieu len server gill!, tang tinh bao mat vi an town da lieu Sau hoan thien co ban irng dung, tac gia se nghien cuu tim hieu xay dung chuong trinh rieng de nhap da lieu Dieu khong chi phuc vu cho dy an san pham Luyen thi TOEIC ma can phuc vu cho cac du in sau di ve chuong trinh luyen thi frac nghiem tren smartphone d Dua img dung len cac kho img dung Dye tuyen MOt img dung den duce yin ngueri dung nhanh nhat thi an phai dua len cac kho fing dung true tuyen nhu CH play vi cac Apps strore Day la nhIIrng kho true tiep de ngtesi ding mua hoac tai img dung Ngoai viec dau Or de dua img dung len cac kho tare tuyen, thai gian Mu ding can phai quang cao yeti ban be de to met cong dang nguti sir dung, beci vi met Inv dung c6 so luqt tai vi danh gia cao se thu but ngtrei sir dung hon 78 PHD LUC — CODE MOT se CH& NANG CH1NH Chat nang kiem tra kit not mang 1.1 Native code a Giri you cau kiem tra ket not mang ten eic thiet bi void PlatformInterface::callOutCheckNetworkConnection () Document document; Document::AllocatorType& allocator = document.GetAllocator(); Value objParams(kArrayType); Value objPost(kObjectType); objPost.AddMember("functionName", THIRTPARTY CHECK INTERNECT, allocator); objPost.AddMember("params", objParams, allocator); //convert to json string StringBuffer strbuf; Writer writer(strbuf); objPost.Accept(writer); string strPostData = strbuf.GetString(); PlatformInterface::getIns()->callOut(strPostData.c str()); ] b Nhan ket qua tra ve bool PlatformInterface::callOutIsNetworkAvailible() callOutCheckNetworkConnection(); return isNetworkAvailable; 1.2 Android code boolean isNetworkConnectionAvailable() ( (ConnectivityManager) cm ConnectivityManager getSystemService(Context.CONNECTIVITY SERVICE); Networkinfo info = cm.getActiveNetworkInfo(); if (info == null) return false; State network = info.getState(); 79 == return (network == Networklnfo.State.CONNECTED II network NetworkInfo.State.CONNECTING); 1.3 IOS code BOOL networkReachable() struct sockaddr in zeroAddress; bzero(&zeroAddress, sizeof(zeroAddress)); zeroAddress.sin_len = sizeof(zeroAddress); zeroAddress.sin_family = AF INET; reachabilityRef SCNetworkReachabilitYRef SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault , (constru kad*)&zeroAs; SCNetworkReachabilityFlags flags; if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) ( if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) // if target host is not reachable return NO; if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) // if target host is reachable and no connection is required // then we'll assume (for now) that your on Wi-Fi return YES; // This is a wifi connection if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) II(flags & kSCNetworkReachabilitYFlagsConnectionOnTraffic) != 0)) // and the connection is on-demand (or on-traffic) if the calling application is using the CFSocketStream or // higher APIs if ((flags & kSCNetworkReachabilitYllagsInterventionRequired) == 0) ( // and no (user] intervention is needed return YES; // This is a wifi connection 80 kSCNetworkReachabilityFlagsIsWWAN) & ((flags if kSCNetworkReachabilityFlagsIsWWAN) ( // but WWAN connections are OK if the calling application // is using the CFNetwork (CFSocketStream?) APIs return YES; // This is a cellular connection I return NO; I ChuningkiemtratiiteptinveghivalobOnhtfrsirdyngHttpRequest a thriyeucau void ImageUr1LoaderUtil::downLoadFile( std::string url, CCObject* target ,SEL CallFunc0 fuac, std::string tag ) ImageUr1LoaderUtil* loader = new ImageUr1LoaderUtil(); loader->retain(); loader->target = target; loader->selector = func; loader->tag = tag; CCHttpRequest* request = new CCHttpRequest(); request->setUrl(url.c str()); request->setRequestType(CCHttpRequest::kHttpGet); request->setResponseCallback(loader, callfuncND selector(ImageUr1LoaderUtil::onHttpDownLoadRequestCo mpleted)); request->setTag(tag.c str()); CCHttpClient::getInstance() - >send(request); request->release(); b Nhan phin hoi tir Server void Download::downloadFileCallBackComplete( CCObject* obj ) AsyncData* aData = (AsyncData*)obj; if(aData->error == 200 ) if(writeFile(aData->data, aData->size, aData->tag.c str())) 81 ErrorDowload* errorDowload = new ErrorDowload(); errorDowload->fileName = this->tag.c str(); errorDowload->index = this->index; (target->*selector)(errorDowload); else I returnError(aData); c Ghi tip tin vao 60 nith bool Download::writeFile( unsigned char* data, long fileName ) size, const char* I std::string filePath; filePath = CCFileUtils::sharedFileUtils() - >getWritablePath() fileName; FILE *fp = fopen(filePath.c str(), "wb+"); //CCLog("1 d sizeof data", sizeof(*data)); if(fp) I [write (data , sizeof(unsigned char), size, fp); fclose(fp); return true; CCLog("thu muc ko ton tai"); return false; Chtic niing ttio da thi a Tao toan bel de thi void FullTest::generateToeicTest() I //Lay du lieu moi part vao m vListQuestionlD tuong ung for (int i = 0; i < 7; i++) 82 for (int j = 0; j < ToeicData::getIns()->s_vDatari].size(); j++) mvListQuestionIDM.push_back(ToeicData::getIns() >svDat[i].(j); //Tao de thi to m vListQuestionID for (int i = 0; i < 7; i++) std::vector data = m vListQuestionID(i]; switch (i) default: break; case 0: generateToeicTest(10, data); break; case 1: generateToeicTest(30, data); break; case 2: generateToeicTest(10, data); break; case 3: generateToeicTest(10, data); break; case 4: generateToeicTest(40, data); break; case 5: generateToeicTest(4, data); break; case 6: int totalQs = 0; int ran = rand() 83 data.size(); int questionID = data.at(ran); Value &IkData = ConfigLoaderngetInstance() >1kReadi n g; Conf gLoader::getInstance() - &val Value >getItem(lkData, ran); if (totalQs >= 43) if (val("numn).GetInt() + totalQs == 47) continue; I totalQs +- val("num").GetInt(); pushAllQuestionDataInTopicFromJsonToDataTemp(questionID); data.erase(data.begin() + ran); I while (totalQs < 48); break; I I b Lay a bai ngau nhien cu s& dU ligu void FullTest::generateToeicTest( int num, std::vector &data ) for (int j = 0; j < num; j++) int ran = rand() % data.size(); int questioniD = data.at(ran); pushAllQuestionDataInTopicFromJsonToDataTemp(guestionID); data.erase(data.begin() + ran); I I c Dua de bai vio b0 nit tam void MCQBase::pushAllQuestionDataInTopicFtomJsonToDataTemp( int questionID ) int totalQuestion getTotalQuestionInTopicByQuestionID(questionID); int topiciD getTopicIDByQuestionID(questionID); int searchFirst = questionlD - totalQuestion; if(searchFlrst < 0) 84 searchFirst = 0; Value 61kData - Con f igLoader: : getIns Canoe ()->IkReading; int temp = 0; for (int i = sea rchFirst; i c questionID + totalQuestion; i++) temp++; if (temp totalQuestion + 1) break; Value 6va = ConfigLoader:: getlnstance (1 ->getItem ( lkData , i); if (topiciD )- val ("id") GetInt 0) temp ; continue; QuestionItem qsData; //Client qsData setChoice (-1); //14C4 qsData setQuestion (val ("qs").GetString () ) ; qsData.setAnswerA(val("a") GetString O ) ; qsData.setAnswerB(val "b" j GetString O); qsData.setAnswerC (val("c") GetString (I I ; qsDa ta setAnswerD (val("d") GetS [ring O); qsData setAnswer (val(mans") Getlnt ) ; //Topic qsData setTopicID(val ("id") Getlnt ) ; qsDa ta setTotalQuestion (val ("num") Getlnt ; qsDa ta setImageURL (vat( "img") GetString ) ; qsDa ta setSoundURL (val( "sound") GetString O); qsData set Topi cContent (val ("txt").GetString ()); qsData.setTopicType (val ("type") Getlnt O); if (qsData.getAnswer () -1) sortData (qsData); m vDataTemp.push back (qsData); 85 TAI LIEU THAM ICHAO Sich Jeff McWherter va Scott Gowell, Professional Mobile Application Development, Wrox, 2012 Packt, 2013 Roger Engelbert, Cocos2d-X by Example Beginner's Guide, Cocos2d-X Game Frahaan Hussain, Arutosh Gurung va Gareth Jones, Development Essentials, Packt, 2014 Website htto://www.Cocos2d-X.ora/ httos://developer.android.comitools/sdkindk/index.html 86

Ngày đăng: 04/07/2016, 00:09

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN