DrawImage failing on IOS
Monkey Targets Forums/iOS/DrawImage failing on IOS
| ||
Been trying some IOS code out to basically shuffle a pack of cards deal them into 2 piles and then display the cards in the order of the 2 piles. My code works great on HTML5 but when I try to run on the IOS simulator it crashed out with this error in Xcode Thread 1 : Program received signal: "EXC_BAD_ACCESS" and the line highlighted is bbgraphicscontext->bbdevice->DrawSurface2(bbimage->bbsurface,bbx-bbimage->bbtx,bby-bbimage->bbty,bbf->bbx,bbf->bby,bbimage->bbwidth,bbimage->bbheight); My source code is as follows Import mojo Class ShowCard Extends App Field deck:Image Field cardsnotpicked:Int Field playercards:=[New Int[2],New Int[26]] Field ctr1:Int Field ctr2:Int Field ctr3:Int Field ctr4:Int Field ctr5:Int Method OnCreate () deck = LoadImage ("cards.png", 79, 123, 65,Image.MidHandle ) SetUpdateRate 60 cardsnotpicked=1 End Method OnUpdate() If cardsnotpicked ' fill the card arrays with a blank card For ctr1 = 0 To 1 For ctr2 = 0 To 25 playercards[ctr1][ctr2]=54 Next Next 'find an empty slot to put the next card in For ctr3 = 0 To 51 ctr1 = Rnd(0,2) ctr2 = Rnd(0,26) While playercards[ctr1][ctr2]<>54 ctr1 = Rnd(0,2) ctr2 = Rnd(0,26) Wend playercards[ctr1][ctr2]=ctr3 Next cardsnotpicked = 0 End End Method OnRender () Cls (20,240,20) 'draw 2 x 26 cards For ctr4 = 0 To 1 For ctr5 = 0 To 25 DrawImage deck,100+(ctr4*20),100+(ctr5*18),playercards[ctr4][ctr5] Next Next End End Function Main() New ShowCard End Any ideas on why its doing it? Thanks Gary |
| ||
Can you try just drawing one frame of your deck image? |
| ||
one frame at random works fine Thing that I find strange is it is highlighting the scale and rotate part of the draw code which im not using Looking at the Xcode code it has converted DrawImage deck,100+(ctr4*20),100+(ctr5*18),playercards[ctr4][ctr5] to bbgraphicsDrawImage2(bbdeck,float(100+bbctr4*20),float(100+bbctr5*18),0.000000f,1.000000f,1.000000f,bbplayercards[bbctr4][bbctr5]); if I replace bbplayercards[bbctr4][bbctr5] with 1 then it draws the same card over and over again with no issues. Have I declared the array properly or is it an issue with 2d arrays with xcode? Like I say it works as expected in HTML5 |
| ||
Field playercards:=[New Int[2],New Int[26]] As I posted in your Arrays thread, this is not doing what you think. You are declaring an Array with two elements: the first a two element Int array and the second is a twenty six element Int array. I presume what you are trying to do is declare an array with two rows of 26 elements, like this: Field playercards:=[New Int[26],New Int[26]] Also note the the OnRender is called before the OnUpdate, so you'll need to set your cards up in the OnCreate. |