我想让一个球慢慢向我的老鼠移动.
我使用paper.js这是一个简单的动画库.使用这个我有一个球在屏幕上移动.这些是球的一些属性:
球[0] .vector.angle是它的方向.0 =正确,90 =向下,180 =向左等等,其间的一切
balls [0] .point.x是x的位置,y是y的位置.
球[0] .vector.length是它的速度.
我已经进行了鼠标移动事件,我认为我们之间的角度是:
canvas.addEventListener("mousemove", function(e){
var a = balls[0].point.y - e.clientY;
var b = balls[0].point.x - e.clientX;
var angleDeg = Math.atan2(a, b) * 180 / Math.PI;
});
Run Code Online (Sandbox Code Playgroud)
所以我让球静止不动以测试它并将鼠标移动到它周围.球的左边给我0度.上面给了我90.右边给我180.球下面给了我-90等以及介于两者之间的一切.
然后我计算了同一事件中的距离,并改变了速度以反映距离,给出了最大速度上限:
var distance = Math.sqrt( a*a + b*b );
var maxSpeed = 20;
balls[0].vector.length = (distance/30 > maxSpeed) ? maxSpeed : distance/30;
Run Code Online (Sandbox Code Playgroud)
所以我测试了速度和它,它的工作完美.当我向球提供从各个方向前进的角度.速度仍然有效,它只是球走向错误的方向,我不知道我做错了什么.
我有一个简单的日期输入
<input type="date" id="sign-up-dob" class="sign-inputs" max="2999-12-31"></input>
Run Code Online (Sandbox Code Playgroud)
它看起来像这样:
我将如何摆脱打开日期选择器右侧的箭头和东西。我只是想要它,以便您可以输入带有验证的日期,谢谢。
我今天遇到了这个问题,想知道为什么要在php和js中处理数组方面做到这一点。
JS
let x = [];
let i = x;
i.push('test');
console.log(x);
//prints ['test']
Run Code Online (Sandbox Code Playgroud)
的PHP
$x = [];
$i = $x;
array_push($i, 'test');
print_r($x);
/prints []
Run Code Online (Sandbox Code Playgroud) 我正在开发一个程序,我需要从不同的线程激活一个计时器.我已经将代码缩短到下面这个例子.
static class Program
{
public static System.Windows.Forms.Timer TimerVideo = new System.Windows.Forms.Timer();
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
TimerVideo.Interval = 1000;
TimerVideo.Tick += new EventHandler(TimerVideo_Tick);
new Thread(() =>
{
test RunTimer = new test();
RunTimer.StartTimer();
}).Start();
Application.Run();
}
private static void TimerVideo_Tick(object sender, EventArgs e)
{
Console.WriteLine("Running");
}
}
class test
{
public void StartTimer()
{
Program.TimerVideo.Start();
}
}
Run Code Online (Sandbox Code Playgroud)
即使我必须在课堂上对计时器进行编码对我来说没问题,但我确实尝试过,但它也没有用,即计时器没有触发,也没有打印到控制台.
我有一款游戏,当玩家丧生时,我希望他们能够再次观看视频。
我正在使用unity版本2018.1.1f1人,并且我已经下载了admob unity插件版本3.13.1
因此,如果玩家同意观看广告,则该广告将播放,然后继续游戏,而不会触发奖励玩家的回调。这是我的代码:
using System;
using UnityEngine;
using GoogleMobileAds.Api;
using UnityEngine.UI;
public class RewardAd : MonoBehaviour {
private BannerView bannerView;
private InterstitialAd interstitial;
private RewardBasedVideoAd rewardBasedVideo;
private float deltaTime = 0.0f;
private static string outputMessage = string.Empty;
public AudioSource musicPlayer;
public Player player;
public Text UIText;
public static string OutputMessage
{
set { outputMessage = value; }
}
public void Start()
{
#if UNITY_ANDROID
string appId = "ca-app-pub-3940256099942544~3347511713";
#elif UNITY_IPHONE
string appId = "ca-app-pub-3940256099942544~1458002511";
#else
string appId = "unexpected_platform"; …Run Code Online (Sandbox Code Playgroud)