• Tidak ada hasil yang ditemukan

LAMPIRAN A: Listing Program

N/A
N/A
Protected

Academic year: 2019

Membagikan "LAMPIRAN A: Listing Program"

Copied!
25
0
0

Teks penuh

(1)

9 */&*%- - $#

1. $&*0$% (%.,*/

if(tipebelajar == "latihanmenulis") {

SceneMenulis>>removeChild(HurufTulis,true); SceneMenulis>>removeChild(Tulisan[0],true); SceneMenulis>>removeChild(Tulisan[1],true); SceneMenulis>>removeChild(Tulisan[2],true);

string idx = intTostr(idxbaca); string str = "images/menulis/soal/"; if(tipemenulis == "tunggal") {

str += idx + ".png";

}else if(tipemenulis == "bersambung") {

str += "kata_" + idx + ".png"; }else{

str += "ubah_" + idx + ">" + intTostr(idxTouch) + ".png"; }

HurufTulis = CCSprite::spriteWithFile(str.c_str());

HurufTulis>>setPosition(ccp(centerWin.x,centerWin.y + 118)); SceneMenulis>>addChild(HurufTulis,2);

HurufTulis>>setScale(factorscale); // add code //

int arrIdx[6]= {18,19,22,24,27,28};

(2)

{

str = "images/menulis/penulisan/"; if(tipemenulis != "perpenulisan") {

str += idx + "_" + intTostr(i+1) + ".png"; }else{

str += intTostr(arrIdx[atoi(idx.c_str())>1]) + "_" + intTostr(i+1) + ".png";

}

Tulisan[i] = CCSprite::spriteWithFile(str.c_str()); Tulisan[i]>>setPosition(ccp(390 >(i*150),170)); SceneMenulis>>addChild(Tulisan[i],1);

}

// cek tipe penulisan //

if(tipemenulis == "tunggal" || tipemenulis == "bersambung") {

for(int i=0; i<3; i++)

{

Tulisan[i]>>setIsVisible(false);

CCSprite * sfchild = (CCSprite*)SceneMenulis> >getChildByTag(20+i);

sfchild>>setIsVisible(false);

CCSprite * sfktk = (CCSprite*)SceneMenulis> >getChildByTag(25+i);

sfktk>>setIsVisible(false); }

}else{

for(int i=0; i<3; i++)

{

Tulisan[i]>>setIsVisible(true);

(3)

sfchild>>setIsVisible(true);

CCSprite * sfktk = (CCSprite*)SceneMenulis> >getChildByTag(25+i);

sfktk>>setIsVisible(true); }

}

LoadDataHuruf(idxbaca);

// revisi code , tampilin tulisan latin//

if(tipemenulis == "tunggal") {

string tulisanlatin =

"alif,ba,ta,tsa,jim,ha,kha,dal,dzal,ra,zay,sin,syin,shad,dhad,tha,dzha,ayn,ghayn,fa,qaf,k

af,lam,mim,nun,waw,hha,ya";

string latin = GetItemPos(tulisanlatin,idxbaca); LabelLatin>>setString(latin.c_str());

} } }

void Hijaiyah::menuCloseCallback(CCObject* pSender) {

// "close" menu item clicked

CCDirector::sharedDirector()>>end(); }

void Hijaiyah::HijaiyahUpdate(ccTime dt) {

UpdateImageDraw(); }

bool Hijaiyah::isPointOnSprite(CCSprite * psf,CCPoint pos) {

(4)

float x1,y1,x2,y2,scale_x,scale_y;

scale_x = psf>>getScaleX();// simpan skala gamabar scale_y = psf>>getScaleY();

x1 = psf>>getPosition().x > ((psf>>getContentSizeInPixels().width*scale_x) / 2);

y1 = psf>>getPosition().y > ((psf>>getContentSizeInPixels().height*scale_y) / 2);

x2 = psf>>getContentSize().width * scale_x; y2 = psf>>getContentSize().height * scale_y;

CCRect rect1 = CCRectMake(x1,y1,x2,y2);

if(CCRect::CCRectContainsPoint(rect1,pos)) {

return true; }

return false; }

void Hijaiyah::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) {

// Choose one of the touches to work with

CCTouch* touch = (CCTouch*)( pTouches>>anyObject() ); CCPoint location = touch>>locationInView(touch>>view()); location = CCDirector::sharedDirector()>>convertToGL(location); location = AllScene>>convertToNodeSpace(location);

if(bolehdraw && setTilePos == true) {

(5)

if(idxTmp <29)

{

idxTmp += 1; }

return; }

}

if(maingame && drag == false) {

for(int i=0; i<jlhacak; i++) {

if(this>>isPointOnSprite(HurufSoal[i],location) &&

HurufSoal[i]>>getOpacity() >= 255) {

LastPos = HurufSoal[i]>>getPosition(); idxdrag = i;

drag = true;

HurufSoal[i]>>setPosition(location); break;

} }

} }

void Hijaiyah::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) {

// Choose one of the touches to work with

CCTouch* touch = (CCTouch*)( pTouches>>anyObject() ); CCPoint location = touch>>locationInView(touch>>view()); location = CCDirector::sharedDirector()>>convertToGL(location);

(6)

if(bolehdraw)

{

// cek jawaban //

if(udahbenar == false) {

bool tmpb = true;

for(int i=0; i<MaxDat; i++) {

if(DataID[i] == 1) {

tmpb = false; i = MaxDat; }

} if(tmpb) {

unsigned int tsfx = this>>playEffect("sound/benar");

udahbenar = true;

// revisi code //

if(tipemenulis == "tunggal") {

string tulisanlatin =

"alif,ba,ta,tsa,jim,ha,kha,dal,dzal,ra,zay,sin,syin,shad,dhad,tha,dzha,ayn,ghayn,fa,qaf,k

af,lam,mim,nun,waw,hha,ya";

string sfx_string = "sound/latin/"; string latin = this>

>GetItemPos(tulisanlatin,idxbaca);

sfx_string += latin;

tsfx = this>>playEffect(sfx_string.c_str()); }

(7)

} }

if(this>>isPointOnSprite(Erase,location)) {

if(!setTilePos) {

EraseDraw(); return; }

} }

if(tipebelajar == "membaca" || tipebelajar == "menulis")

{

if(SceneHuruf>>getPosition().x == centerWin.x) {

for(int i = 0; i<28; i++) {

if(this>>isPointOnSprite(Huruf[i],location)) {

if(tipebelajar == "membaca") {

SceneHuruf>>setPosition(ccp(> 1000,centerWin.y));

SceneMembaca>>setPosition(centerWin); idback = "mengeja";

idxbaca = (i+1);

tipebelajar = "mengeja"; GantiHuruf();

(8)

SceneHuruf>>setPosition(ccp(> 1000,centerWin.y));

SceneMenulis>>setPosition(centerWin); idback = "menulis";

bolehdraw = true; EraseDraw(); jlhdrawpoint = >1; idxbaca = (i+1);

tipebelajar = "latihanmenulis"; GantiHuruf();

} return;

} }

} }

// add code //

if(SceneMenulis>>getPosition().x == centerWin.x) {

// cek touch kotak //

if(tipemenulis == "perpenulisan") {

for(int i=0; i<3; i++)

{

if(this>>isPointOnSprite(Tulisan[i],location)) {

idxTouch = (i+1); EraseDraw(); GantiHuruf();

sfblank>>setIsVisible(false); return;

(9)

} }

// lepas jawaban //

if(maingame && drag==true) {

drag = false;

for(int i=0; i<jlhsoal; i++) {

if(isikotak[i] == false) {

if(this>>isPointOnSprite(Kotak[i],location))

{

// cek jawaban //

if(isisoal[i] == isipilih[idxdrag]) {

unsigned int tsfx = this>

>playEffect("sound/benar");

// jawaban benar//

LastPos = Kotak[i]>>getPosition(); jlhbenar += 1;

isikotak[i] = true;

HurufSoal[idxdrag]>>setOpacity(254); if(jlhbenar >= jlhsoal)

{

maingame = false;

pNext>>setIsVisible(true); }

} break; }

(10)

HurufSoal[idxdrag]>>setPosition(LastPos); idxdrag = >1;

}

if(this>>isPointOnSprite(sfsound,location))//cek touch tombol suara.... {

if(ismute == false)

{

sfsound>>setTexture(pTexture2); // ganti texture gambar SimpleAudioEngine::sharedEngine()>

>pauseBackgroundMusic(); //pAUSE suuara ismute =true;//

}else {

sfsound>>setTexture(pTexture1); SimpleAudioEngine::sharedEngine()> >resumeBackgroundMusic();

ismute = false; }

} }

unsigned int Hijaiyah::playEffect(string path) {

string exc = ".wav";

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) exc = ".ogg";

#endif

SimpleAudioEngine::sharedEngine()>>setEffectsVolume(1.0f);

string str = path + exc;

(11)

return tSfx;

}

//BELAJAR MENULIS//

void Hijaiyah::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) {

CCTouch* touch = (CCTouch*)( pTouches>>anyObject() ); CCPoint location = touch>>locationInView(touch>>view()); location = CCDirector::sharedDirector()>>convertToGL(location); location = AllScene>>convertToNodeSpace(location);

//mencari titik tengah rectangle//

if(bolehdraw && udahbenar == false && sfblank>>getIsVisible() == false)

{

CCPoint ploc = location;//SceneMenulis> >convertToNodeSpace(location);

if(setTilePos)

{

sfTemp[idxTmp]>>setPosition(ploc);

string strloc = "Posisi = ";

strloc += intTostr((int)ploc.x) + " , " + intTostr((int)ploc.y); tDebug>>setString(strloc.c_str());

return; }

// cek rect //

float x1,y1,x2,y2; float valX,valY;

// revisi code //

(12)

{

if(DataID[i] == 1)// belum aktif // {

valX = (float)(atoi(this>>GetItemPos(DatX,i+1).c_str())) ;

valY = (float)(atoi(this>>GetItemPos(DatY,i+1).c_str())) ;

float calc = (18*factorscale);

x1 = valX > calc; y1 = valY > calc; x2 = valX + calc; y2 = valY + calc;

if(ploc.x >= x1 && ploc.x <= x2 && ploc.y >= y1 && ploc.y <= y2) //CEK COLLISION DETECTION //

{

DataID[i] = 0;

sfTemp[i]>>setPosition(ccp(valX,valY));

uruttouch += 1; return;

} }

} return; }

if(maingame && drag==true)

{

// ikut posisi touch move //

(13)

}

void Hijaiyah::LoadDataHuruf(int idx) {

// default //

DatX = "227,231,223,252,238,244,249,246,247"; DatY = "634,600,567,567,533,498,465,435,408"; // add code //

switch(idx) {

case 1:

if(tipemenulis == "tunggal") {

// factorscale = 0.8f//

DatX = "234,232,235,238,241,243,243,241"; DatY = "610,581,553,532,505,478,452,425";

}else if(tipemenulis == "bersambung") {

DatX =

"333,333,300,300,267,267,235,236,208,202,207,198,165,168,321,318,312,297,251,23

5,190,173,157,145";

DatY =

"513,480,510,476,516,482,517,495,557,523,490,465,470,503,562,528,606,572,556,46

3,575,550,593,560";

}else {

//'ain

if(idxTouch == 1) {

DatX =

"275,245,215,208,211,226,240,240,268,268,292,288,210,210,188,188";

DatY =

(14)

}else if(idxTouch == 2) {

DatX =

"284,284,256,256,241,226,227,253,253,267,261,226,226,203,203,187,193";

DatY =

"491,482,493,486,510,527,545,543,535,537,520,493,483,491,482,491,483";

}else if(idxTouch == 3) {

DatX =

"299,299,270,270,240,240,228,213,222,237,246,251,248,210,201,195,200,210,215,21

5,243,243,271,271,290";

DatY =

"526,517,530,516,536,525,552,571,587,576,585,571,561,537,518,491,462,453,447,43

8,446,433,442,436,448";

} }

break;

case 2:

if(tipemenulis == "tunggal") {

DatX =

"313,311,311,281,281,253,253,225,225,197,197,173,170,168,247";

DatY =

"532,505,477,481,468,475,462,471,461,473,461,466,486,510,422";

}else if(tipemenulis == "bersambung") {

DatX =

"342,333,302,296,280,263,263,245,241,237,211,201,200,182,170,341,327,271,222,17

(15)

DatY =

"506,472,476,480,501,500,465,471,505,536,473,482,515,523,496,532,560,531,560,55

0,576,562,596";

}else{

//ghoin

if(idxTouch == 1)

{

DatX =

"262,233,203,195,198,213,227,227,255,255,281,275,198,198,175,175,220,220,235,23

6";

DatY =

"527,530,530,518,489,479,469,459,479,465,484,471,453,463,460,454,587,572,573,58

0";

}else if(idxTouch == 2) {

DatX =

"287,287,258,258,241,223,223,248,248,267,263,230,230,200,200,185,185,235,241,25

0";

DatY =

"465,457,468,460,486,506,523,525,511,517,493,467,457,466,457,467,457,582,568,57

7";

}else if(idxTouch == 3) {

DatX =

"303,303,275,275,245,245,235,218,230,247,247,261,257,215,201,202,203,217,231,24

1,258,268,297,232,238,252";

DatY =

"493,483,500,483,505,490,523,540,557,556,543,546,528,503,476,448,421,406,421,40

2,410,406,412,611,596,603";

} }

(16)

case 3:

if(tipemenulis == "tunggal") {

DatX =

"313,311,311,281,281,253,253,225,225,197,197,173,170,168,253,225";

DatY =

"532,505,477,481,468,475,462,471,461,473,461,466,486,510,546,543";

}else if(tipemenulis == "bersambung") {

//jamalun

DatX =

"291,322,336,303,272,248,246,215,215,187,191,190,193,181,145,135,141,307,312,28

0,253,220,176,161,136,150";

DatY =

"532,527,498,502,493,527,493,510,475,501,533,566,601,468,467,500,521,466,578,56

5,571,555,578,553,565,600";

}else{ //kaf

if(idxTouch == 1) {

DatX =

"266,266,238,238,223,227,238,257,271,274,274,244,244,214,214,185,185";

DatY =

"575,566,566,551,551,530,521,512,497,471,463,471,463,471,463,471,463";

}else if(idxTouch == 2) {

DatX =

"290,290,260,260,257,240,226,210,207,227,227,251,250,230,230,200,200,183,183";

DatY =

(17)

}else if(idxTouch == 3) {

DatX =

"270,277,271,275,280,286,286,315,315,258,258,228,228,198,198,175,175,172,180,23

5,225,240,233,205";

DatY =

"575,558,551,522,492,462,447,455,446,455,446,455,446,457,448,466,453,488,506,55

8,530,521,501,496";

} }

break; case 4:

if(tipemenulis == "tunggal") {

DatX =

"313,311,311,281,281,253,253,225,225,197,197,173,170,168,233,253,225";

DatY =

"532,505,477,481,468,475,462,471,461,473,461,466,486,510,571,546,543";

}else if(tipemenulis == "bersambung") {

DatX =

"295,328,337,336,303,270,268,237,225,205,187,182,146,326,292,231,211,210,182,16

2,135,147";

DatY =

"505,505,505,471,471,485,516,481,515,481,495,453,443,550,535,539,535,573,536,51

5,521,555";

}else {

//mim

if(idxTouch == 1) {

DatX =

(18)

DatY =

"505,498,491,511,531,546,540,518,502,492,502,492";

}else if(idxTouch == 2) {

DatX =

"297,297,268,268,258,252,252,238,238,223,222,230,200,200,177,177";

DatY =

"502,491,498,491,527,536,545,506,495,506,535,542,505,492,500,492";

}else if(idxTouch == 3) {

DatX =

"306,306,278,278,260,255,249,246,225,215,250,225,225,205,201,210,213";

DatY =

"538,525,532,525,540,550,560,567,567,557,526,530,518,517,490,463,441";

} }

break;

case 5:

if(tipemenulis == "tunggal") {

DatX =

"190,218,218,247,247,273,225,200,188,190,190,210,210,238,238,265,292,310,241";

DatY =

"572,578,568,575,567,570,552,533,505,477,458,457,441,445,437,437,443,448,502";

}else if(tipemenulis == "bersambung") {

//hirun

DatX =

"267,300,300,300,267,267,250,250,220,225,218,195,160,331,300,216,203,167,160,17

6,197";

DatY =

"570,550,516,493,535,500,527,492,538,505,472,462,461,473,455,598,563,560,575,60

(19)

}else{ //ha

if(idxTouch == 1) {

DatX =

"238,246,258,271,283,293,281,265,260,243,228,230,255,251,225,225,205,205,185,18

5";

DatY =

"560,551,542,525,508,479,461,481,468,482,497,522,518,501,477,470,477,467,477,46

7";

}else if(idxTouch == 2) {

DatX =

"297,297,268,268,238,238,255,261,251,251,230,220,215,215,226,243,253,256,251,24

0,198,198,177,177";

DatY =

"492,483,492,485,490,477,462,450,431,422,429,442,472,502,531,553,561,536,516,51

0,491,483,495,485";

}else if(idxTouch == 3) {

DatX =

"297,297,270,266,258,253,248,250,235,216,207,207,230,230";

DatY =

"478,467,471,485,513,542,566,581,546,535,507,501,496,508";

} }

break; case 6:

if(tipemenulis == "tunggal")

{

DatX =

(20)

DatY =

"572,578,568,575,567,570,552,533,505,477,458,457,441,445,437,437,443,448";

}else if(tipemenulis == "bersambung") {

//qirdun

DatX =

"300,300,321,318,317,292,261,261,253,230,207,315,287,336,317,266,245,185,181,18

1,146,183,147,155";

DatY =

"521,551,538,505,492,488,513,483,448,446,450,585,582,475,445,548,547,541,507,47

3,488,577,563,598";

}else{ //ya

if(idxTouch == 1) {

DatX =

"265,270,270,270,240,240,210,210,180,180,263,255,230,233";

DatY =

"548,520,500,488,496,486,496,486,495,488,452,446,443,433";

}else if(idxTouch == 2) {

DatX =

"291,291,278,278,250,255,255,225,225,195,195,190,187,246,245,215,214";

DatY =

"512,503,510,505,561,533,505,511,505,512,505,511,503,471,460,463,451";

}else if(idxTouch == 3) {

DatX =

"315,315,285,285,255,250,278,270,240,225,197,197,173,168,173,187,233,210";

DatY =

"541,532,541,533,536,516,507,482,478,475,475,485,478,505,533,556,446,443";

(21)

} break;

case 7:

if(tipemenulis == "tunggal") {

DatX =

"202,230,258,263,228,202,192,198,211,231,248,276,293,233";

DatY =

"548,547,545,546,532,511,481,452,442,437,435,437,442,586";

}else if(tipemenulis == "bersambung") {

DatX =

"343,343,311,280,282,273,346,312,231,211,213,248,190,181,176,141,245,225,180,16

3,135,142";

DatY =

"506,528,513,508,540,576,561,546,551,543,511,521,515,530,481,480,498,465,563,57

2,566,598";

} break;

case 8:

DatX = "245,245,260,270,275,265,265,235,235,220,225"; DatY = "546,533,532,518,488,471,480,476,468,476,468"; break;

case 9:

DatX = "245,245,260,270,275,265,265,235,235,220,225,240"; DatY = "546,533,532,518,488,471,480,476,468,476,468,582"; break;

case 10:

(22)

DatY = "532,510,481,452,438,432,433"; break;

case 11:

DatX = "265,271,280,269,255,240,215,253"; DatY = "532,510,481,452,438,432,433,573"; break;

case 12: DatX =

"315,318,306,290,288,266,266,250,251,245,230,215,190,190,170,163,172";

DatY =

"536,508,493,497,518,496,490,505,476,446,431,426,425,433,427,456,483";

break;

case 13: DatX =

"315,318,306,290,288,266,266,250,251,245,230,215,190,190,170,163,172,275,292,26

8";

DatY =

"536,508,493,497,518,496,490,505,476,446,431,426,425,433,427,456,483,585,561,55

6";

break; case 14:

DatX =

"251,251,268,291,316,312,290,268,233,235,226,205,175,163,165";

DatY =

"493,510,533,548,548,521,510,506,515,487,458,448,451,462,491";

break; case 15:

DatX =

"251,251,268,291,316,312,290,268,233,235,226,205,175,163,165,262";

DatY =

"493,510,533,548,548,521,510,506,515,487,458,448,451,462,491,570";

(23)

DatX =

"226,223,226,227,227,227,248,262,290,291,273,250,203,183";

DatY =

"567,540,512,483,456,438,481,493,495,466,452,445,442,450";

break; case 17:

DatX =

"226,223,226,227,227,227,248,262,290,291,273,250,203,183,263";

DatY =

"567,540,512,483,456,438,481,493,495,466,452,445,442,450,536";

break; case 18:

DatX =

"235,207,195,203,231,248,253,210,190,185,190,205,215,226,255,283,295";

DatY =

"573,570,541,525,525,535,542,508,487,458,430,420,412,406,403,407,410";

break;

case 19: DatX =

"235,207,195,203,231,248,253,210,190,185,190,205,215,226,255,283,295,213";

DatY =

"573,570,541,525,525,535,542,508,487,458,430,420,412,406,403,407,410,612";

break;

case 20: DatX =

"296,296,276,278,293,308,316,310,299,283,268,250,235,235,205,205,178,175,165,16

1,165,278";

DatY =

"502,490,493,522,531,522,493,465,452,446,440,436,430,436,437,431,432,442,447,47

5,483,571";

(24)

DatX =

"270,270,251,252,268,281,290,288,273,253,238,238,210,210,193,185,188,195,277,25

1";

DatY =

"483,471,472,501,515,505,476,447,426,417,408,415,411,422,420,447,475,488,558,55

6";

break; case 22:

DatX =

"273,275,282,287,279,276,248,248,220,220,192,195,222,223,235,220,213";

DatY =

"568,540,511,482,452,443,446,440,445,438,456,438,533,512,502,492,491";

break; case 23:

DatX =

"271,271,277,281,282,273,260,260,230,230,203,205,195,196,205";

DatY =

"576,548,520,492,463,434,423,417,421,415,425,415,438,467,482";

break; case 24:

DatX = "225,242,255,259,262,259,230,213,208,218,225,226"; DatY = "546,553,547,532,527,515,517,511,482,453,425,418"; break;

case 25: DatX =

"268,273,282,271,255,240,240,213,213,202,198,206,231";

DatY =

"527,507,478,452,445,437,442,438,450,452,481,500,547";

break;

case 26:

(25)

case 27:

DatX =

"238,267,283,291,302,301,301,271,245,235,243,270,267,235,210,183,168";

DatY =

"533,533,518,505,491,463,456,458,470,483,507,505,482,457,451,446,443";

break;

case 28: DatX =

"310,310,280,270,255,255,282,306,300,281,251,235,223,223,195,197,175,187,173,17

2,185,251,251,222,223";

DatY =

"566,577,570,556,531,508,508,502,480,467,462,460,455,463,464,453,463,476,490,51

7,542,423,416,420,413";

break; }

uruttouch = 0;// revisi code urutan touch

MaxDat = this>>GetCountItem(DatX); for(int i=0; i<30; i++)

{

if(i < MaxDat) {

DataID[i] = 1; }else{

DataID[i] = 0; }

Referensi

Dokumen terkait

* To change this template, choose Tools | Templates. * and open the template in

function edit1_CreateFcn(hObject, eventdata, handles) if ispc &amp;&amp; isequal(get(hObject, 'BackgroundColor' ), get(0, 'defaultUicontrolBackgroundColor' )).

function edit1_CreateFcn(hObject, eventdata, handles) if ispc &amp;&amp; isequal(get(hObject, 'BackgroundColor' ), get(0, 'defaultUicontrolBackgroundColor' )).

&lt;li&gt; Pengajuan klaim kerusakan atau ketidaksesuaian barang terhadap spesifikasi harus diajukan maksimum dalam waktu 3 hari setelah barang diterima, Barang yang telah di

[r]

// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.. // Parse the strings

WordScramble.as package { import flash.display.MovieClip; import flash.media.Sound; import flash.events.MouseEvent; import flash.net.URLLoader; import flash.net.URLRequest;

Klik Save Result untuk menyimpan hasil analisa pada memo result ke dalam format .txt.. Isi nilai alpha