如何设置一个androidH亚军的游戏对象 [英] How to set objects on a androidH runner game

查看:258
本文介绍了如何设置一个androidH亚军的游戏对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一款Android游戏亚军上学的目的.. 我还是新的这一点,请我需要你的帮助。

I am trying to develop a android runner game for school purpose.. I am still new to this and please I need your assistance..

你们可以>>> http://www.filedropper.com/test_37

障碍和硬币是随机的。但是,障碍和硬币相互重叠..这是非常坏的亚军游戏,因为它看起来很糟糕,游戏性变得非常非常复杂。

The obstacles and coins are on random. But the obstacles and coins are overlapping each other.. Which is very bad for a runner game because it looks very bad and the gameplay gets very very complicated.

我怎样才能解决这个问题?。有什么办法解决它?

How can i fix it??. Is there any way to fix it?.

,我也想,如果我可以设置的障碍和硬币到一个特定的区域(未随机)。因此本场比赛将更加oganized和游戏性将不会被复杂化。我仍然不知道-_-。

And i am also thinking if I can set the obstacles and coins to a specific area (not on random). So the game will be more oganized and the gameplay won't be complicated. Which i still don't know -_-.

但我还是preFER它随机的。所以,球员请帮我解决这个问题。

But i still prefer it on random. So guys please help me fix it..

推荐答案

您需要更改您要添加的硬币和障碍的方式!我建议使用的每一个计时器。 ATM要添加一吨他们对每一帧,计算重叠会使用过多的资源!并把它们放在一个阵列或更好的向量!我会建议使用对象池藏汉!

You will need to change the way you are adding the coins and obstacles! I suggest using a timer for each. Atm you are adding a ton of them on every frame, calculating overlaps would use too much resources! and put them in an array or better a vector! i would reccomend using an object Pool aswell!

所以限制硬币和障碍的大写金额,可以是present,像5左右。然后从阵列/矢量去除他们,他们是屏幕之外或收集时!那么当你添加新的东西,你可以检查对数组/向量允许值是什么!

so limit the amout of coins and hurdles that can be present, like 5 or so. then remove them from the array/vector when they are offscreen or collected! then when you add new stuff you can check against the array/vector what the allowed values are!

当你有你的数组,你可以将它传递给 randomRange()功能和exlcude这些值! 看起来财产以后这个样子!不testet !!

when you got your Array you can pass it to the randomRange() function and exlcude those values! would look somthing like this! not testet!!

function randomRange (min:Number, max:Number, exclude:Array = null):int
{
    var val:int = (min + Math.random() * (max - min)) >> 0;
    if (exclude)
    {
        for (var i:int = 0; i < exclude; i++)
        {
            while ((val < exclude[i].x + exclude[i].width) && (val > exclude[i].x))
            {
                val = (min + Math.random() * (max - min)) >> 0;
            }
        }
    }
    return val;
}

它还是相当exspensive性能明智的。但只有少数几个对象,你应该罚款

Its still quite exspensive performance wise. but with only a few object you should be fine

这篇关于如何设置一个androidH亚军的游戏对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆