假设我在2D空间中有一个可以旋转的物体,然后应该根据其旋转角度移动.
例如:
如果角度为0(向上指向),那么on_timer它应该将Y移动1,将X移动X.
如果角度为45,那么它应该由Y移动1和X移动1.
如果指向90度,则0表示Y,1表示X.
如果指向135度,则由Y表示-1,由X表示+1,等等.
你知道计算这个的任何函数吗?
我刚学习wcf,目前已经走到了这一步.
CS档案:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace wcfLib
{
[ServiceContract]
public interface IfaceService
{
[OperationContract]
int wordLen(string word);
}
public class StockService : IfaceService
{
public int wordLen(string word)
{
return word.Length;
}
}
}
Run Code Online (Sandbox Code Playgroud)
然而,当我试图运行它时,它会弹出一个错误:
WCF服务主机找不到任何服务元数据...
知道它可能是什么?
配置文件:
<system.serviceModel>
<services>
<service behaviorConfiguration="wcfLib.Service1Behavior" name="wcfLib.Service1">
<endpoint address="" binding="wsHttpBinding" contract="wcfLib.ser">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/wcfLib/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wcfLib.Service1Behavior"> …Run Code Online (Sandbox Code Playgroud) 我有这个代码,绘制图像.
private void timer1_Tick(object sender, EventArgs e)
{
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
var tempRocket = new Bitmap(Properties.Resources.rocket);
using (var g = Graphics.FromImage(tempRocket))
{
e.Graphics.DrawImage(tempRocket, 150, 150);
}
}
Run Code Online (Sandbox Code Playgroud)
然而我该如何旋转呢?
private void button3_Click(object sender, EventArgs e)
{
this.DoubleBuffered = true;
for (int i = 0; i < 350; i++)
{
using (Graphics g = this.CreateGraphics() )
{
g.Clear(Color.CadetBlue);
g.DrawImage(Properties.Resources._256, 100, 100, i-150, i-150);
}
}
}
Run Code Online (Sandbox Code Playgroud)
然而,我认为我将DoubleBuffered设置为true,图像仍然闪烁.有什么想法我做错了什么?谢谢!