Online game problem! Please help ASAP!

  1. – Abstract: Move Vectors in realtime. Lets users drag update vector positions
  2. – and updates the new positions on all clients.
  3.  
  4. – create global warp client and initialize it
  5. appWarpClient = require “AppWarp.WarpClient”
  6.  
  7. – Replace these with the values from AppHQ dashboard of your AppWarp app
  8. API_KEY = “secret”
  9. SECRET_KEY = “secret”
  10. STATIC_ROOM_ID = “secret”
  11.  
  12. appWarpClient.initialize(API_KEY, SECRET_KEY)
  13.  
  14. – uncomment if you want to enable trace printing of appwarp
  15. –appWarpClient.enableTrace(true)
  16.  
  17. – IMPORTANT! loop WarpClient. This is required for receiving responses and notifications
  18. local function gameLoop(event)
  19. appWarpClient.Loop()
  20. end
  21.  
  22. Runtime:addEventListener(“enterFrame”, gameLoop)
  23.  
  24. – do the appwarp client related handling in a separate file
  25. require “warplisteners”
  26.  
  27. statusText = display.newText( “Connecting…”, 10, display.contentHeight, native.systemFontBold, 24 )
  28. statusText.width = 128
  29.  
  30. appWarpClient.connectWithUserName(tostring(os.clock()))
  31.  
  32. button = {}
  33.  
  34. – Iterate through arguments array and create rounded rects (vector objects) for each item
  35. for i = 1, 2 do
  36.     local button1 = display.newRoundedRect( 50*i*2, 60, 100, 100, 10 )
  37.     button1.strokeWidth = 6
  38.     button1:setStrokeColor( 200,200,200,255 )
  39.     button[i] = button1
  40. end
  41.  
  42. local function onTouch( event )
  43.     local t = button[1]
  44.     local phase = event.phase
  45.     if “began” == phase then
  46.         – Make target the top-most object
  47.         local parent = t.parent
  48.         parent:insert( t )
  49.         display.getCurrentStage():setFocus( t )
  50.         t.isFocus = true
  51.         – Store initial position
  52.         t.x0 = event.x - t.x
  53.         t.y0 = event.y - t.y
  54.     elseif t.isFocus then
  55.         if “moved” == phase then
  56.             – Make object move (we subtract t.x0,t.y0 so that moves are
  57.             – relative to initial grab point, rather than object “snapping”).
  58.             t.x = event.x - t.x0
  59.             t.y = event.y - t.y0
  60.             appWarpClient.sendUpdatePeers(tostring(t.y))
  61.         elseif “ended” == phase or “cancelled” == phase then
  62.             display.getCurrentStage():setFocus( nil )
  63.             t.isFocus = false
  64. – send the update to others in the game room. space delimit the values and parse accordingly
  65. – in onUpdatePeersReceived notification
  66. appWarpClient.sendUpdatePeers(tostring(t.y))
  67.         end
  68.     end
  69.     return true
  70. end
  71. button[1]:addEventListener( “touch”, onTouch )
  72.  
  73. function onConnectDone(resultCode)
  74. if(resultCode == WarpResponseResultCode.SUCCESS) then
  75. statusText.text = “Joining Room…”
  76. appWarpClient.joinRoom(STATIC_ROOM_ID)
  77. elseif(resultCode == WarpResponseResultCode.AUTH_ERROR) then
  78. statusText.text = “Incorrect app keys”
  79. else
  80. statusText.text = “Connect Failed. Restart”
  81. end
  82. end
  83.  
  84. function onJoinRoomDone(resultCode)
  85. if(resultCode == WarpResponseResultCode.SUCCESS) then
  86. appWarpClient.subscribeRoom(STATIC_ROOM_ID)
  87. statusText.text = “Subscribing to room…”
  88. else
  89. statusText.text = “Room Join Failed”
  90. end
  91. end
  92. function onSubscribeRoomDone(resultCode)
  93. if(resultCode == WarpResponseResultCode.SUCCESS) then
  94. statusText.text = “Started!”
  95. else
  96. statusText.text = “Room Subscribe Failed”
  97. end
  98. end
  99.  
  100. function onUpdatePeersReceived(update)
  101. local func = string.gmatch(update, “%S+”)
  102. local y = func()
  103. local x = func()
  104. local buttonasd = button[2]
  105. buttonasd.y = tonumber(y)
  106. end
  107.  
  108. appWarpClient.addRequestListener(“onConnectDone”, onConnectDone)
  109. appWarpClient.addRequestListener(“onJoinRoomDone”, onJoinRoomDone)
  110. appWarpClient.addRequestListener(“onSubscribeRoomDone”, onSubscribeRoomDone)
  111. appWarpClient.addNotificationListener(“onUpdatePeersReceived”, onUpdatePeersReceived)
  112.  

here is a link to video that shows the bug

https://www.youtube.com/watch?v=UJ41buMjXJs&feature=youtu.be

 

Soo, if we come from left to right we can call them boxes 1, 2, 3 and 4. So see in the video, when I move box 3 it moves box 2 AND also box 4. What I want it to do is when I move box 3 it only moves box 2 and not box4.

Same thing happens other way; when I move box 1 it moves box 2 and box 4.

 

So if anyone of you could please help me with this problem as soon as possible.

This is a duplicate question of this thread:

https://forums.coronalabs.com/topic/69965-appwarp-game-test-bug-help/

Please continue the discussion there.

Thanks

Rob

This is a duplicate question of this thread:

https://forums.coronalabs.com/topic/69965-appwarp-game-test-bug-help/

Please continue the discussion there.

Thanks

Rob