IPhone: ANIMCOLL

Previous topic - Next topic

BigAnd

I think there is a bug with ANIMCOLL on the iPhone.

It causes the debugger to stop with an EXC_BAD_ACCESS or the app to just terminate if in release mode.
This is of cause when there is a collision as the app works fine until then.

Code (glbasic) Select

SETCURRENTDIR("Media") // seperate media and binaries?
SETSCREEN 320,480,0
SYSTEMPOINTER TRUE
LIMITFPS 60
SMOOTHSHADING TRUE
LOADANIM "willy.png",0,24,24

GLOBAL MOUSEcount
DIM MOUSEx[10]
DIM MOUSEy[10]
DIM MOUSEb1[10]
DIM MOUSEb2[10]

GLOBAL x1=RND(296)
GLOBAL y1=RND(456)
GLOBAL x2=RND(296)
GLOBAL y2=RND(456)
GLOBAL frame1=RND(7)
GLOBAL frame2=RND(7)
GLOBAL hit=0

WHILE TRUE
MOUSEcount = GETMOUSECOUNT()-1

FOR i=0 TO MOUSEcount
SETACTIVEMOUSE i
MOUSESTATE MOUSEx[i],MOUSEy[i],MOUSEb1[i],MOUSEb2[i]
NEXT
IF KEY(57)
x2=RND(296)
y2=RND(456)
ENDIF

ALPHAMODE -0.999
DRAWANIM 0,frame1/8,MOUSEx[0],MOUSEy[0]
DRAWANIM 0,frame2/8,x2,y2

frame1=MOD(frame1+1,64)
frame2=MOD(frame2+1,64)

hit=0
IF ANIMCOLL(0,frame1/8,MOUSEx[0],MOUSEy[0],0,frame2/8,x2,y2)
hit=1
ENDIF
IF hit=1
PRINT "COLLISION!!!",0,0
ENDIF

SHOWSCREEN
WEND
END


Media:
http://www.andynoble.co.uk/willy.png

Kitty Hello

Oh, I had a bug in that loop. I'll upload an update now.

BigAnd

Excellent. Thanks for the quick fix  =D

tatakamucher

The same bug appears in 118, sometimes if two anim collides the game crash, in the update 202 was the same

Kitty Hello

debug the position of the crash. Then make a 3-line program (loadsprite, sprcoll) with hardcoded numbers. Does it crash?
Otherwise make a small example that crashes. I'm so sorry.

tatakamucher

This is my code, when i use in 10.118 the bug crashes the game about 1 of 20 collisions, when i use 202 is about 5 of 10.

Code (glbasic) Select

IF ANIMCOLL(343,locov, mx,locoy1, 6,0, cositas[i].x, cositas[i].y)
addexplo(cositas[i].x, cositas[i].y,0)
PLAYSOUND(123,0,1)
cositas[i].z = 0
balloons = balloons + 1
ENDIF


i change the line "if animcoll" for this

Code (glbasic) Select

IF cositas[i].x+20 > mx+5 AND cositas[i].x < mx+55 AND  cositas[i].y < locoy1+86 AND cositas[i].y+40 > locoy1


and the game works fine.  :)



Kitty Hello

please make a 10-line example that reproduces the crash and zip the project for me.

tatakamucher

this is an example, in the original i use arrays with types to the enemies and sometimes in the collide crash the game and sometimes not.

Code (glbasic) Select



SETCURRENTDIR("Media") // seperate media and binaries?
SETSCREEN 320,480,0
LOADSOUND "1.wav", 123, 2
LOADANIM "example.png",1,80,24
loadanim "example2.png",10,80,24
global animation#
global animation2#
global x#, x1#, y#, y1#, b1#, b2#

x1 = 320/2
y1 = 480/2
WHILE TRUE
anim1()
        anim2()

FOR i=0 TO GETMOUSECOUNT()-1
      SETACTIVEMOUSE i
      MOUSESTATE x#, y#, b1#, b2#
next

SHOWSCREEN
WEND

function anim1:
inc animation,1
if animation > 8 then animation = 0

drawanimation 1,animation,x,y
endfunction

function anim2:
inc animation,2
if animation2 > 8 then animation2 = 0
drawanimation 10,animation2,x1,y1
IF ANIMCOLL(1,animation,y,y, 10,animation2, x1, y1)
PLAYSOUND(123,0,1)
endif

endfunction









thanks

Kitty Hello

post the example1+2.png, too, please.