javascript canvas检测一个数字

javascript canvas检测一个数字

问题描述:

我正在做一个游戏,想法是收集数字,如果你收集3你获得积分,如果你收集4你失分。数字正在下降所以我需要通过使用按钮上的字符来收集它们,我知道碰撞检测但这还不够,因为它无法识别数字只是重叠。有没有办法(功能)识别画布上的数字?



一切顺利,



Marco

I am doing a game, the idea is to collect numbers if you collect 3 you get points if you collect 4 you lose points. The numbers are falling down so I need to collect them by using a character at the button, I know about collision detection but that is not enough as it cannot recognize numbers just the overlapping. Is there a way (function) to recognize numbers on a canvas?

All the best,

Marco

从你的问题来看,我认为没有必要承认任何事情。如果你在代码中删除数字,你就会知道它们是什么。因此,从这个角度来看,这个问题看起来很简单:你定义了一组数字对象,每个对象都包含你需要的数字,当前位置和其他几何参数。其他一切都是代码设计的问题。你的设计。 :-)



-SA
From your question, I cannot see any need in "recognition" of anything. If you "drop" numbers in your code, you know what are they. So, from this point of view, the problem looks quite trivial: you define a set of number objects each holding the number, current location and other geometric parameters you need to have. Everything else is the matter of the design of your code. Your design. :-)

—SA