(AGK version: 2.0.15)
Submitted: 2015-12-04 07:14:24
//agk 2.0.15d

//falling box at platform with physics

SetVirtualResolution(100,100)
SetPhysicsScale(0.025)

SetPhysicsDebugOn()

spr=createsprite(0)
SetSpritePositionByOffset(spr,50,25)
SetSpritePhysicsOn(spr,2)

platform=createsprite(0)
setspritesize(platform,25,1)
SetSpritePositionByOffset(platform,50,50)
SetSpritePhysicsOn(platform,2)
SetSpritePhysicsCanRotate(platform,0)
platformJoint=CreateMouseJoint(platform, GetSpriteXByOffset(platform), GetSpriteYByOffset(platform), 1000 ) 

ground=createsprite(0)
setspritesize(ground,100,1)
SetSpritePosition(ground,0,99)
SetSpritePhysicsOn(ground,1)

x as float
x=50
w as float
w=0.2

do
	if GetPointerPressed() then exit
	
	x=x+w
	if x>75 and w>0 then w=-w
	if x<25 and w<0 then w=-w
	
	print("Platform x:"+str(x,1))
		
	SetJointMouseTarget(platformJoint,x,50)
		
	print("List:")
	List(spr)
	List(platform)
	List(ground)

	sync()
loop
end

function List(spr)
 
    c=GetSpriteFirstContact(spr)
    do
        if c=0 then exit
        spr2=GetSpriteContactSpriteID2() 
        if spr2<>0
			print(str(spr)+" hit "+str(spr2))
        endif
        c=GetSpriteNextContact()
    loop
 
endfunction
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.