realtime game in Corona

0 votes
Hi everyone,

 I follow the tutorial on this page

http://appwarp.shephertz.com/game-development-center/corona-color-move-walkthrough/

but if I add "appWarpClient.sendUpdatePeers" when moving to be more real time,it always an error,

 

I want to make effect like this

http://appwarp.shephertz.com/game-development-center/Smiley-Shooter-game/

Can it work in Corona?

thanks
asked Mar 8, 2015 in App42 Cloud API-BaaS by heloha44 (20 points)

2 Answers

0 votes
 
Best answer
Hi Heloha, Could you please state the error you are getting on sendUpdatePeers API call? Yes the above sample can be made in Corona too. Thanks Kanika Mittal AppWarp Team
answered Mar 9, 2015 by kanika mittal (50 points)
selected Mar 24, 2015 by heloha44
0 votes

http://i.imgur.com/72UnMe1.jpg

and the following is my code

ps. I just copy the line "appWarpClient.sendUpdatePeers(tostring(t.id) .. " " .. tostring(t.x).." ".. tostring(t.y))"

to moved phase,and it works when I move slowly.

If I move fast,it show error like the picture like that picture

 

local function onTouch( event )
local t = event.target
local phase = event.phase
 
if "began" == phase then
-- Make target the top-most object
local parent = t.parent
parent:insert( t )
display.getCurrentStage():setFocus( t )
t.isFocus = true
-- Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y
elseif t.isFocus then
if "moved" == phase then
-- Make object move (we subtract t.x0,t.y0 so that moves are
-- relative to initial grab point, rather than object "snapping").
t.x = event.x - t.x0
t.y = event.y - t.y0
appWarpClient.sendUpdatePeers(tostring(t.id) .. " " .. tostring(t.x).." ".. tostring(t.y))
elseif "ended" == phase or "cancelled" == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
      print("moved button id ".. tostring(t.id))
      -- send the update to others in the game room. space delimit the values and parse accordingly
      -- in onUpdatePeersReceived notification
      appWarpClient.sendUpdatePeers(tostring(t.id) .. " " .. tostring(t.x).." ".. tostring(t.y))
end
end
return true
end
answered Mar 9, 2015 by heloha44 (20 points)
Hi Heloha,
When sending messages on sendUpdatePeers,if the message size is too big,it is broken into chunks and then transmitted.It seems you are creating and passing your own json here.So please check that the message being sent is complete while sending it.Due to high length of your message it is not being transmitted completely.This is giving the error.

Thanks

Kanika Mittal
AppWarp Team
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...