Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. game.input.onDown.add(function() {
  2. x = Math.floor(game.input.activePointer.worldX / 15);
  3. y = Math.floor(game.input.activePointer.worldY / 15);
  4. arrayData.push("{'x':'" + x+"','Y':'"+y+"'}");
  5. document.getElementById('test').innerHTML = ' Data: {"x":' + x+',"Y":'+y+'}';
  6. console.log(" Data: " + arrayData);
  7. });
  8.  
  9. arrayData.push("{'x':'" + x+"','Y':'"+y+"'}");
  10.  
  11. arrayData.push({'x': x,'Y': y});
  12.  
  13. var obj = {
  14. 'x': Math.floor(game.input.activePointer.worldX / 15),
  15. 'y': Math.floor(game.input.activePointer.worldY / 15)
  16. };
  17. arrayData.push(obj);
  18.  
  19. $.ajax({
  20. type: 'POST',
  21. url: "CollectData.jsp",
  22. data: {xydata:arrayData},
  23. dataType: "json",
  24. success: function(resultData) {
  25. alert("here");
  26. console.log("New Data :"+resultData);
  27. //$("#list").html(resultData);
  28. }
  29. });
  30.  
  31. String data =request.getParameter("xydata");
  32. JSONObject obj = new JSONObject();
  33. obj.put("arr", data);
  34.  
  35. try {
  36. FileWriter file = new FileWriter("D:\test\testFile.json");
  37. file.write(obj.toJSONString());
  38. file.flush();
  39. file.close();
  40. } catch (IOException e) {
  41. e.printStackTrace();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement