2016-09-06 105 views
0
//obj 1 has that: 
if (place_meeting(x,y, obj_nomatter)){ 
global.points -= 1; 
moveawayfromobj_nomatter(); 
// obj 1 rotates. 
} 

问题是点有时会减少一个或七个。 算法的任何想法?谢谢!游戏机制造商工作室place_meeting

+0

您的问题很模糊,缺乏上下文。请修改它,以便我们清楚你想做什么,你期望得到什么结果......以及你得到的是什么 – user919426

+1

为了改善你从问题中得到的回应,考虑做一些事情,比如发布一个[minimal,complete和可验证的示例](http://stackoverflow.com/help/mcve),[语法突出显示](http://meta.stackexchange.com/questions/184108/what-is-syntax-highlighting-and-how-does - 工作),在标题中明确提出问题,[添加必要的标签](http://stackoverflow.com/help/tagging)... [和标题常见问题](http:// stackoverflow .com/help/how-to-ask)获取更多信息 – user919426

回答

0

您使用的是在步骤事件 所以它调用的动作一个或七次如果你仍然发生碰撞的七个步骤

一种方法是使用定时器或变量

这样: 这是使用可变

var ones = false; 
if(!ones) { 
    if(place_meeting(x,y,obj_nomatter)) { 
    global.points -= 1; 
    ones = true; 
    } 
} 

这是使用定时器

step event: 
if(place_meeting(x,y,obj_nomatter)) {alarm[0] = room_speed;} 
//to use the room_speed, 30 for default (a second) 

alarm[0]: 
global.points -= 1; 

//with this method if you collide more than room_speed global.points keeps going down 
012的方法,所述方法
+0

噢,天啊,我是怎么忘记这种方法的!非常感谢你!!! – Raphael