宇宙飞船问答游戏 Actionscript 3
我在接下来的比赛中需要认真的帮助。 我想在游戏中加入一些问题和答案,玩家必须给出正确的答案。 因此,三个答案就像敌人一样从右边出现,但速度很慢。
我怎样才能用 Actionscript 3 做到这一点? 该游戏采用 OOP ActionScript 3 编写,并结合 Flash Pro。
您可以在这里玩游戏: http://stap.iam.hva.nl/~sahina002/Spaceship/basics2 .html
我使用了这段代码,但不知道如何实现它。
vragen = new Vector.<QuizVraag>;
// vragen.push(
// new QuizVraag("Wat is een boom?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 0), // Vraag 0
// new QuizVraag("Wat is een auto?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 1), // Vraag 1
// new QuizVraag("Wat is een bus?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 2), // Vraag 2
// new QuizVraag("Wat is een fiets?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 0), // Vraag 3
// new QuizVraag("Wat is een stoel?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 2) // Vraag 4
// );
package com.quiz
{
public class QuizVraag
{
private var _vraag:String;
private var _antwoorden:Array;
private var _correcteAntwoordIndex:int;
public function QuizVraag(vraag:String, antwoorden:Array, correcteAntwoordIndex:int)
{
_vraag = vraag;
_antwoorden = antwoorden;
_correcteAntwoordIndex = correcteAntwoordIndex;
}
public function optieIsCorrect(mijnAntwoordIndex:int):Boolean
{
return _correcteAntwoordIndex == mijnAntwoordIndex;
}
public function get vraag():String
{
return _vraag;
}
public function get correcteAntwoord():String
{
return _antwoorden[_correcteAntwoordIndex];
}
public function get correcteAntwoordIndex():int
{
return _correcteAntwoordIndex;
}
public function get antwoorden():Array
{
return _antwoorden;
}
}
}
谢谢,
阿里
I need serious help with the following game.
I want to put some questions and answers in the game, where the player has to shoot the right answer.
So the 3 answers come onto stage from the right just like the enemies but slowly.
How can I do this with Actionscript 3 ?
The game is written in OOP actionscript 3, combined with Flash Pro.
You can play the game here:
http://stap.iam.hva.nl/~sahina002/Spaceship/basics2.html
I used this code but dont know how to implement it.
vragen = new Vector.<QuizVraag>;
// vragen.push(
// new QuizVraag("Wat is een boom?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 0), // Vraag 0
// new QuizVraag("Wat is een auto?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 1), // Vraag 1
// new QuizVraag("Wat is een bus?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 2), // Vraag 2
// new QuizVraag("Wat is een fiets?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 0), // Vraag 3
// new QuizVraag("Wat is een stoel?", ["Antwoord 0", "Antwoord 1", "Antwoord 2"], 2) // Vraag 4
// );
package com.quiz
{
public class QuizVraag
{
private var _vraag:String;
private var _antwoorden:Array;
private var _correcteAntwoordIndex:int;
public function QuizVraag(vraag:String, antwoorden:Array, correcteAntwoordIndex:int)
{
_vraag = vraag;
_antwoorden = antwoorden;
_correcteAntwoordIndex = correcteAntwoordIndex;
}
public function optieIsCorrect(mijnAntwoordIndex:int):Boolean
{
return _correcteAntwoordIndex == mijnAntwoordIndex;
}
public function get vraag():String
{
return _vraag;
}
public function get correcteAntwoord():String
{
return _antwoorden[_correcteAntwoordIndex];
}
public function get correcteAntwoordIndex():int
{
return _correcteAntwoordIndex;
}
public function get antwoorden():Array
{
return _antwoorden;
}
}
}
Thanks,
Ali
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,
到目前为止,您所拥有的代码是解决某个索引是否是正确答案的逻辑。
但是您缺少有关显示答案以及子弹碰撞的所有逻辑。
基本上,您需要的是一个将答案作为 DisplayObjects (可能是 Sprites )推送的引擎,该引擎将具有与主题关联的图像和索引。由于答案是唯一的整数,您可以使用相同的键(答案索引和 z 索引/深度索引)
然后您只需检查碰撞(您可以在 onEnterFrame 事件上执行此操作),为每个 displayObject 又名运行测试碰撞答案,如果发生冲突,您可以使用您提供的逻辑来设置结果是否正确。
希望有帮助!
Ok,
So far what you have on that code is the logic to solve if a certain index is the correct answer.
But you are missing all the logic about displaying answers, and bullet collision to them.
Basically what you need is an engine which pushes the answers as DisplayObjects ( probably Sprites ) that will have an image and an index associated to theme. Since answers are unique integer numbers you could use the same key ( answer index & z-index / depth index )
Then you only have to check for collisions ( you may do that on onEnterFrame event ), run a test collision for every displayObject aka answer and if there is a collision you can use the logic you provided to set if the result is correct or not.
Hope it helps!