简体   繁体   English

游戏制作者-检查碰撞与子图像

[英]Game Maker - Check Collision With Subimages

I have an obj_roulette , which contains 4 subimages, with value 2-5 and image_number 0-3 . 我有一个obj_roulette ,其中包含4 obj_roulette图像, value 2-5image_number 0-3 The value result from roulette stored as var global.roulette . 轮盘的值结果存储为var global.roulette

Then, I make many obj_meteorite , which contains 4 subimages too, spawn from above with random x value and random image_number . 然后,我制作了许多obj_meteorite ,它也包含4 obj_meteorite图像,它们是从上方以random x valuerandom image_number Player can shoot them with left-mouse click. 玩家可以单击鼠标左键射击它们。

This is what I want: 这就是我要的:

If image_number obj_roulette is 0, and player shoot obj_meteorite with image_number 0, score +10. If image_number obj_roulette is 0, and player shoot obj_meteorite with image_number 1, score -10.

I don't know how to check collision between mouse_x/mouse_y and object image_number , and how to match obj_roulette image_number and obj_meteorite image_number . 我不知道如何检查mouse_x/mouse_y与对象image_number之间的冲突,以及如何匹配obj_roulette image_numberobj_meteorite image_number

Is it using collision checking? 使用冲突检查吗? If it yes, then maybe the examples in these links can help: link 1 link 2 如果是,那么这些链接中的示例可能会有所帮助: 链接1 链接2

Please explain your answer. 请解释您的答案。 Thanks. 谢谢。

I assume this is the kind of game where you click with your mouse and hit exactly where the mouse was clicked. 我认为这是一种您用鼠标单击并完全单击鼠标的地方的游戏。 And as I understand it from your question. 从您的问题中我了解到这一点。 If the mouse is clicked and obj_roulette's image_index is the same as obj_meteorite, you want to add 10 to the score. 如果单击鼠标,并且obj_roulette的image_index与obj_meteorite相同,则您希望将分数加10。 If not, you want to subtract 10 from the score. 如果不是,则要从分数中减去10。 And you need help converting your pseudo-code into gml. 而且您需要帮助将您的伪代码转换为gml。

// Check if obj_meteorite was clicked
if (mouse_check_button_released(mb_left) && position_meeting(mouse_x, mouse_y, obj_meteorite))
{
    // Check wheter or not obj_meteorite's and obj_roulette's image_index is the same
    if (obj_meteorite.image_index == obj_roulette.image_index)
    {
        // Add 10 to the score
        score += 10;
    }
    else
    {
        // Subtract 10 from the score
        score -= 10;
    }
}

If this is not what you want, I suggest editing your question to make it more clear. 如果这不是您想要的,我建议编辑您的问题以使其更清楚。 Preferably explain shortly what your game is actually about. 最好简短地解释一下您的游戏实际上是关于什么的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM