:: I cant get two devices to work together. They connect, everything works fine, then after a few sec disconnect.
:: If I connect to my PC then to any device it works, and vice versa.
everything is up to date.. even AGK2 player on all devices.
Thanks for your time.
SetVirtualResolution(1080,1920)
LoadImage ( 1, "green.png" )
LoadImage ( 2, "red.png" )
CreateSprite ( 1, 1 )
SetSpritePosition ( 1, (1080/2)-200, 200 )
SetSpriteSize ( 1, 100, 100 )
CreateSprite ( 2, 2 )
SetSpritePosition ( 2, (1080/2)+200, 200 )
SetSpriteSize ( 2, 100, 100 )
State = 0
Type1 = 0
NetworkID = 0
x as integer
y as integer
do
if State = 0 // in both programs if State = 0, it will loop to ubtaining a selection
Print ( "Select yellow chip to host a game" )
Print ( "Select blue chip to join a game" )
if GetPointerPressed ( ) = 1
hit = GetSpriteHit ( GetPointerX ( ), GetPointerY ( ) )
if ( hit = 1 )
NetworkID = HostNetwork ( "AGK Test Game", "Player 1", 1029 )
Type1 = 0
endif
if ( hit = 2 )
NetworkID = JoinNetwork ( "AGK Test Game", "Player 2" )
Type1 = 1
endif
State = 1
endif
endif // end of "State" if command
if State = 1 and IsNetworkActive ( NetworkID ) <> 0 // in both programs "State" will change to 1
id = GetNetworkFirstClient ( NetworkID ) // and inter a second constant loop.
while id <> 0
Print ( GetNetworkClientName ( NetworkID, id ) )
id = GetNetworkNextClient ( NetworkID )
SetNetworkLatency(NetworkID, 1)
endwhile
if Type1 = 0
x = GetPointerX()
y = GetPointerY()
SetSpritePosition ( 1, x, y )
message2 = CreateNetworkMessage ( )
AddNetworkMessageInteger ( message2, x )
AddNetworkMessageInteger ( message2, y )
SendNetworkMessage ( NetworkID, 0, message2 )
endif
if Type1 = 1
message2 = GetNetworkMessage ( NetworkID )
while message2 <> 0
x = GetNetworkMessageInteger( message2 )
y = GetNetworkMessageInteger( message2 )
SetSpritePosition ( 1, x, y )
DeleteNetworkMessage ( message2 )
message2 = GetNetworkMessage ( NetworkID )
endwhile
endif
else
print("disconnect")
endif
Sync ( )
loop