基于拖放的HTML5游戏(HTML5 game based on drag and drop)
我正在构建一个基于拖放的HTML5游戏,但我想让对象自动移动,因为我不使用画布,有什么替代方法可以用于kinetic.js吗?
I'm building an HTML5 game based on a drag and drop but i'd like to make the object moving automatically, since i'm not using canvas, is there any alternative i can use to the kinetic.js ?
原文:https://stackoverflow.com/questions/15182872
最满意答案
您需要先取消套接字上的读取操作。 堡垒他,使用
CancellationToken
。创建一个全局
CancellationTokenSource
:CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
调用
DataReader.LoadAsync()
传递一个标记:uint s = await _dataReader.LoadAsync(1024).AsTask( cancellationTokenSource.Token);
最后,当你想放弃一切时,请致电取消:
cancellationTokenSource.Cancel();
但是,在这种情况下,
LoadAsync()
调用将以TaskCanceledException
结束。您不再需要丢弃套接字,套接字将在取消读取操作时关闭。
You will need to cancel the read operation on the socket first. Fort his, use a
CancellationToken
.Create a global
CancellationTokenSource
:CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
When calling
DataReader.LoadAsync()
pass a token:uint s = await _dataReader.LoadAsync(1024).AsTask( cancellationTokenSource.Token);
Finally, when you want to abandon everything, call cancel:
cancellationTokenSource.Cancel();
However, in this case, the
LoadAsync()
call will end withTaskCanceledException
.You don't need to dispose the socket anymore, the socket will be closed as part of cancelling the read operation.
相关问答
更多-
事实证明,我的代码没有任何问题。 我的USB加密狗调制解调器一直在断开连接,导致上面的问题。 通过几个不同的连接进行测试,一切都很好。 As it turns out, there was nothing wrong with my code. My USB dongle modem, kept dropping the connection which resulted in the issue above. Tested this over a couple of different connectio ...
-
无法处置StreamSocket(Can't dispose StreamSocket)[2023-06-20]
您需要先取消套接字上的读取操作。 堡垒他,使用CancellationToken 。 创建一个全局CancellationTokenSource : CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); 调用DataReader.LoadAsync()传递一个标记: uint s = await _dataReader.LoadAsync(1024).AsTask( cancellation ... -
UWP C#.net StreamSocket和HostName中的用户令牌(UWP C# .net StreamSocket with User Token in HostName)[2023-06-20]
当我尝试使用带有用户令牌的URI时,出现“参数不正确”异常。 HostName构造函数的参数不是URI ,而是包含hostname或IP地址的字符串。 根据hostName参数的描述,它可以包含以下内容之一: 可由域名系统(DNS)或其他名称空间提供商解析的主机的名称。 与本地计算机上以下文件中的字符串匹配的主机的名称:%WINDIR%\ system32 \ drivers \ etc \ hosts 包含主机的IPv4或IPv6网络地址的字符串。 对于"//example.myexample.com/w ... -
您可以尝试从Python获取页面:将字符串打印为十六进制字节? 并在你的outpt上使用encode('hex')作为my_show的一部分: return ':'.join(x.encode('hex') for x in fvalue) You could try taking a page from Python: print a string as hex bytes? and use encode('hex') on your outpt as part of my_show: return ' ...
-
在这里工作正常......你怎么知道它没有连接? C。 [随意删除,不能发表评论] Works fine here ... how do you know it is not connecting? C. [Feel free to delete, cannot post comments]
-
一种方法是在App.xaml.cs中的静态属性中声明它: public static StreamSocket Socket { get; set; } 然后您可以从应用程序的任何位置访问它: await App.Socket.ConnectAsync(peer.HostName, "{00001101-0000-1000-8000-00805F9B34FB}"); One way could be to declare it in a static property in your App.xaml. ...
-
默认情况下, LoadAsync将不会阻塞,直到读取了所有请求的字节。 您可能正在收到部分消息。 正如我在博客中描述的那样,您需要实现协议使用的任何类型的消息框架 。 PS避免async void 。 它确实使您的错误处理变得复杂。 I changed the return type of Connect() to Task. Then called it as such, await Connect(); I put send and receive code in separate methods an ...
-
使用StreamSocket传输文件并接收错误的数据(UWP)(Use StreamSocket to transfer files and receive wrong data (UWP))[2023-04-22]
我刚刚解决了这个问题。 在接收代码中,我使用了等待FileIO.WriteBufferAsync(文件,缓冲区); 将缓冲区写入文件。 此方法不能将缓冲区追加到文件。 所以我使用OutputStream.WriteAsync()来处理它。 I solved this question just now. In receive code, I use await FileIO.WriteBufferAsync(file, buffer); to write buffer to file. This metho ... -
结果我没有终止我的命令。 添加Environment.Newline到最后解决了问题。 Turns out I wasn't terminating my command. Adding Environment.Newline to the end solved things.
-
Windows 10 UWP应用程序:通过移动宽带的StreamSocket(Windows 10 UWP app: StreamSocket via mobile broadband)[2023-07-27]
我使用以下代码,允许我通过WiFi连接到所需的设备,但它无法通过移动宽带连接工作。 这不是StreamSocket连接的问题,因此您无法找到有关需要为移动互联网连接使用不同套接字类型的任何信息。 “10.203.120.71”是一个LAN IP地址,当您的计算机连接到WiFi路由器时,此路由器首先连接到您公司的网络,换句话说,您的计算机都连接到公司的LAN内部。 但是当您使用手机的宽带时,手机的网络位于公司的局域网之外,因此无法通过此“10.203.120.71”地址连接此手机。 该设备包含一个机器对机器S ...