我正在尝试完成有关如何在 XNA 中创建 Shooter 2D 游戏的 App Hub 教程 - 位于此处:http : //xbox.create.msdn.com/en-US/education/tutorial/2dgame/getting_started
该项目包含一堆图形和一些音频文件。但是当我在我的计算机上构建解决方案时,希望它写道:
Error 1 Failed to open file gameMusic.mp3. Ensure the file is a valid audio file and is not DRM protected.
Run Code Online (Sandbox Code Playgroud)
现在我知道提供的音频文件不受 DRM 保护,但作为测试,我使用一个程序重新“录制” MP3 并保存它(应该删除任何 DRM 保护),我尝试同时保存它MP3 和 WMA,但结果相同。最后我尝试随机录制自己的 MP3,但效果相同。
该错误在项目构建时出现,因此它不是“播放器”问题,而是 XNA 中我相信的某些内容,或者我的计算机中缺少某些内容。
有没有人知道为什么会发生这种情况以及如何解决?
我正在使用 Visual Studio 2010 Ultimate 和 Windows Phone 开发人员工具,如教程(上面链接)中所述
我正在使用HTML和JavaScript为漫画创建一个简单的Web应用程序.因为不太技术的人应该能够添加新的漫画,所以我考虑使用XML文件作为配置文件.
我考虑过使用JSON并决定反对它,主要是因为逗号的使用方式(两个项之间没有逗号会破坏它,但是列表末尾的逗号也会破坏它.).
但是,我现在的问题是:如何嵌入此XML文件?我是否使用<link rel= />标签或标签等其他内容<embed src= />?那我怎样才能从JavaScript中读取XML节点的信息呢?
typedef enum
{
HEARTS = 0,
SPADES,
DIAMONDS,
CLUBS
}Suits; //here HEARTS = 0, SPADES = 1, DIAMONDS = 2, and CLUBS = 3
int main()
{
Suits hand;
play(hand);
return 0;
}
void play(Suits hand)
{
printf("Testing.\n");
}
Run Code Online (Sandbox Code Playgroud)
当我编译与此类似的内容时,编译器给出错误:隐式声明函数“play”和警告:“菜单”可能在此函数中未初始化地使用。我该如何解决这些问题?
String s1 = new String("string");
String s2 = new String("string");
String s3 = "string";
String s4 = "string";
System.out.println(s1 == s2); //FALSE
System.out.println(s2.equals(s1)); //TRUE
System.out.println(s3 == s4); //TRUE
System.out.println(s3.equals(s4)); //TRUE
Run Code Online (Sandbox Code Playgroud)
创造s1和有s3什么区别?请告诉我
在String中我们只有String对象,那么为什么它以不同的方式处理这两个.s1和s2具有不同的存储器地址,而s3和s4具有相同的存储器地址.为什么它基于new运营商.
正如标题所说"根据元素的数量划分元素宽度"我希望有一个类似进度的栏,我可以在其中添加元素,并且根据我有进度条的元素量将分开.

这是现在的固定值(33%,33%和34%),我希望它们根据我使用的元素数量而改变.
就像我的列表中有4个元素一样,我希望它能自动与4分开.有没有简单的方法可以做到这一点?也许只使用CSS?我不介意javascript,但我只是说它可能是我错过的东西:)
编辑:我创建了3个div并给了他们所有不同的类.
<section class="progress-part-list">
<div class="progress-part-left">
</div>
<div class="progress-part-right">
</div>
<div class="progress-part-mid">
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
在我的CSS中,我的固定值是:
.progress-part-mid
{
height: 100%;
width: 34%;
background-color: #52ff00;
opacity: 0.9;
display: block;
float:left;
}
.progress-part-left
{
height: 100%;
width: 33%;
background-color: red;
opacity: 0.9;
display: block;
border-top-left-radius: 50px;
border-bottom-left-radius: 50px;
float:left
}
.progress-part-right
{
height: 100%;
width: 33%;
background-color: yellow;
opacity: 0.9;
display: block;
border-top-right-radius: 50px;
border-bottom-right-radius: 50px;
float:right;
}
Run Code Online (Sandbox Code Playgroud) 我有一个从System.Windows.Forms.Button继承的自定义按钮类.
我想在winform项目中使用这个按钮.
此类称为"ConfirmButton",它显示带有"是"或"否"的确认消息.
但问题是,当用户选择否带有确认消息时,我不知道如何停止点击事件.
这是我的班级来源.
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace ConfirmControlTest
{
public partial class ConfirmButton : System.Windows.Forms.Button
{
public Button()
{
InitializeComponent();
this.Click += Button_Click;
}
void Button_Click(object sender, EventArgs e)
{
DialogResult res = MessageBox.Show("Would you like to run the command?"
, "Confirm"
, MessageBoxButtons.YesNo
);
if (res == System.Windows.Forms.DialogResult.No)
{
// I have to cancel button click event here
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果用户从确认消息中选择"否",则不再触发按钮单击事件.
这个HTML:
<div style="border:1px solid blue; margin: auto; height:250px; width:600px;">
<div style="border:1px solid red; height:50px; width:80px;"></div>
<div style="border:1px solid red; height:50px; width:80px;"></div>
<div style="border:1px solid red; height:50px; width:80px;"></div>
<div style="border:1px solid red; height:50px; width:80px;"></div>
</div>Run Code Online (Sandbox Code Playgroud)
为什么红色div不在同一水平行中,如何将它们放在同一行?
我有一组html标签,要在选中它们时突出显示。我正在尝试使用jquery来做到这一点。但这似乎不起作用。
$(function () {
setNavigation();
});
function setNavigation() {
var path = window.location.pathname;
path = path.replace(/\/$/, "");
path = decodeURIComponent(path);
$(".nav a").each(function () {
var href = $(this).attr('href');
if (path.substring(0, href.length) === href) {
$(this).closest('li').addClass('active');
}
});
}Run Code Online (Sandbox Code Playgroud)
a {
color:#000;
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
a:visited {
color:#000;
}
.nav {
padding:10px;
border:solid 1px #c0c0c0;
border-radius:5px;
float:left;
}
.nav li {
list-style-type:none;
float:left;
margin:0 10px;
}
.nav li a {
text-align:center;
width:55px;
float:left;
}
.nav li.active {
background-color:green; …Run Code Online (Sandbox Code Playgroud)我试图让city出来的Geolocation API.我刚开始学习JS和jQuery,所以这可能是一个基本的错误.
$(document).ready(function(){
function displayLocation(latitude,longitude){
var request = new XMLHttpRequest();
var method = 'GET';
var url =
'http://maps.googleapis.com/maps/api/geocode/json?latlng='
+ latitude + ',' + longitude + '&sensor=true';
var async = true;
request.open(method, url, async);
request.onreadystatechange = function(){
if(request.readyState == 4 && request.status == 200){
var data = JSON.parse(request.responseText);
var address = data.results[0];
alert(address.city.short_name);
}
};
request.send();
};
var successCallback = function(position){
var x = position.coords.latitude;
var y = position.coords.longitude;
displayLocation(x,y);
};
navigator.geolocation.getCurrentPosition(successCallback);
});
Run Code Online (Sandbox Code Playgroud) 我的老师要求我们以最有效的方式制作一个程序,并为此使用一个开关盒.
程序要求用户输入,并且根据用户输入的内容,程序必须遵循一组指令.
如果输入是"A"或"a",则必须从A到Z对数组进行排序.
如果输入为"Z"或"z",则数组必须从Z到A排序.
如果输入为"R"或"r",则必须反转阵列.
数组是一个字符串[].
所以我想知道它是否更有效
switch (choice.ToLower())
{
case "a":
Array.Sort(array);
break;
case "z":
Array.Sort(array);
Array.Reverse(array);
break;
case "r":
Array.Reverse(array);
break;
}
Run Code Online (Sandbox Code Playgroud)
要么
if (choice.ToLower() == "a" || choice.ToLower() == "z")
{
Array.Sort(array);
}
if (choice.ToLower() == "r" || choice.ToLower() == "z")
{
Array.Reverse(array);
}
Run Code Online (Sandbox Code Playgroud)
如果这个代码可以进一步优化.
那么,是使用开关案例的最有效方式,还是如上所示的if结构并解释原因?
我只是好奇,因为我总是试图完全优化我的所有代码.