Hi!
I need some help! when i try collision with for example coin nothing happens, what i m doing wrong?
This is the code
[rem
rem AppGameKit Application
rem
rem Landscape App
SetDisplayAspect( 4.0/3.0 )
rem variaveis
score=0
keyboard = getKeyboardExists()
if keyboard=0
rem create a virtual joystick
AddVirtualJoystick(1,10,88,12)
rem create a jump button
AddVirtualButton(1,90,88,8)
endif
goodguy=1
LoadImage (1,"goodguy.png")
rem create a character
spr = createSprite(1)
SetSpriteShape ( 1, 1 )
setSpriteSize(spr,8,16)
setSpriteOffset(spr,2,4)
setSpritePositionByOffset(spr,54,96)
setSpritePhysicsOn(spr,2)
setSpritePhysicsCanRotate(spr,0)
SetObjectCollisionMode( 1, 1 )
boxman = spr
loadimage (2, "barreira.png")
barreira=2
rem create static platforms
spr = createSprite(2)
setSpriteSize(spr,20,8)
setSpriteOffset(spr,15,1)
setSpritePositionByOffset(spr,15,75)
setSpritePhysicsOn(spr,2)
LoadImage (6, "coin.png")
coin=6
spr = createSprite(6)
SetSpriteShape ( 6, 1 )
setSpriteSize(spr,8,8)
setSpriteOffset(spr,15,1)
setSpritePositionByOffset(spr,85,50)
setSpritePhysicsOn(spr,2)
SetObjectCollisionMode( 6, 1 )
kinematic = spr
direction = 10
spr = createSprite(2)
setSpriteSize(spr,20,8)
setSpriteOffset(spr,15,1)
setSpritePositionByOffset(spr,40,100)
setSpritePhysicsOn(spr,2)
LoadImage (5, "monstro.png")
monstro=5
spr = createSprite(5)
setSpriteSize(spr,15,15)
setSpriteOffset(spr,15,1)
setSpritePositionByOffset(spr,20,15)
setSpritePhysicsOn(spr,2)
rem create a kinematic platform
spr = createSprite(2)
setSpriteSize(spr,20,8)
setSpriteOffset(spr,15,1)
setSpritePositionByOffset(spr,50,15)
setSpritePhysicsOn(spr,3)
kinematic = spr
direction = 10
SetPhysicsDebugOn ( )
rem A Wizard Did It!
do
gosub coincollector
print ("SCORE: " +str(score))
rem update kinematic platform
setSpritePhysicsVelocity(kinematic,0,direction)
if getSpriteYbyOffset(kinematic)>85
direction=-10
else
if getSpriteYbyOffset(kinematic)<15
direction=10
endif
endif
rem add keyboard control here!
rem jump
jump = GetRawKeyPressed(38)
if jump>0
setSpritePhysicsVelocity(boxman,getSpritePhysicsVelocityX(boxman),-jump*60)
endif
rem move boxman
setSpritePhysicsVelocity(boxman,(GetRawKeyState(39)-GetRawKeyState(37))*30,getSpritePhysicsVelocityY(boxman))
SetPrintColor (255,0,0)
Print( ScreenFPS())
Printc("min->")
Print ((timer()/60))
Sync()
loop
coincollector:
if GetPhysicsCollision (boxman,6 )=1
DeleteSprite (6)
print ("tocou")
score=score+1
playsound (13)
endif
Return/code]