AS3 - 寻找最高y坐标为给定的的BitmapData x坐标? [英] AS3 - Finding the highest y-coordinate for a given x-coordinate in BitmapData?

查看:164
本文介绍了AS3 - 寻找最高y坐标为给定的的BitmapData x坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做的一些成熟。以下是我迄今为止: http://megaswf.com/s/2486396 (走动,与arrowkeys跳跃)。

I'm making a platformer. Here is what I have so far: http://megaswf.com/s/2486396 (move around and jump with arrowkeys).

我使用的是地面的位图数据,以测试碰撞玩家的坐标,(行走时上坡尤其是)球员下沉到地面的几个像素。为prevent这一点,我想玩家的y坐标瞬间改变让玩家坐在地上的顶部。这里是我工作的:

I'm using the ground's bitmap data to test collisions with the player's coordinates, and the player is sinking into the ground a few pixels (especially when walking uphill). To prevent this, I want the player's y coordinate to instantly change so that the player is sitting on top of the ground. Here is what I'm working on:

    if (groundClipBmpData.hitTest(rLoc, 255, bLocFuture)) {
        playerClip.y = ???
    }

我想玩家的y坐标改变成为groundClipBmpData的最高像素玩家的x坐标。

I want the player's y-coordinate to change to become the highest pixel of the groundClipBmpData at the player's x coordinate.

我怎样才能做到这一点?

How can I do this?

推荐答案

就像我在其他问题时说:

Like I said in the other question:

使用,而而不是如果

这样的:

while(groundClipBmpData.hitTest(rLoc, 255, playerClipBmpData, bLocFuture, 255))
{
        playerClip.y--;
}
playerClip.y++;

的最快方法是计算和预先存储阵列内的最高的坐标值,然后使用播放器的'x'的位置,以确定所述的y地面。

The fastest way would be to calculate and store the highest coordinate values in advance inside an array and then use the 'x' position of the player to determine the 'y' of the ground.

这篇关于AS3 - 寻找最高y坐标为给定的的BitmapData x坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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