几个月前我开始编程。我正在 Animate CC 中制作完整的客户端游戏,因此我正在尝试针对内存扫描软件的简单措施。
我试图避免人们改变我的金钱变量。
var canMoneyChange = false;
var money = 0;
var previousMoney = 0;
function everyFrame() { //Let's admit that this function is called every frame
if (moneyChange == true) {
lastMoney = money;
canMoneyChange = false;
} else {
if (lastMoney != money) { //If money is "magically" changed it should drop here
resetGame();
}
}
现在,每当我更新货币视觉显示时,我还必须包含布尔变量:
//...
canMoneyChange = true;
money += 100; //For example
updateMoney(); //This is only for visual effects
//...
想知道这是否有效,谢谢。
编辑:该死的,我没有意识到 CE 会同时找到 lastMoney 和 money。我可以做一些事情,比如乘以一个数字来隐藏 lastMoney:
function everyFrame() { //Let's admit that this function is called every frame
if (moneyChange == true) {
lastMoney = money * 8;
canMoneyChange = false;
} else {
if (lastMoney != money * 8) {
resetGame();
}
}