首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >. Flash =‘Flash 1’>闪存中的字符冲突图像(AS2) .怎么做?

. Flash =‘Flash 1’>闪存中的字符冲突图像(AS2) .怎么做?
EN

Stack Overflow用户
提问于 2014-05-08 21:36:07
回答 1查看 178关注 0票数 0

我一直在这里学习本教程- http://www.stormation.info/rpg-game-creation-tutorial/

我试图做一个简单的塞尔达风格的rpg游戏,但在教程中,它使用了一个动态背景。我想使用PNG图像,其中有透明的区域,字符可以走。

就像这样:http://www.imagebam.com/image/de39a1325517813

http://www.imagebam.com/image/5e22e6325517815

http://www.imagebam.com/image/753d56325517819

我要所有的东西,除了透明的区域,以阻止字符。这个是可能的吗?

本教程有碰撞检测功能,但当我将png制作成电影剪辑,然后使用实例“墙壁”与代码对应时,我的角色就会在测试场景时消失。

下面是我当前的As2代码:

代码语言:javascript
复制
onClipEvent(load){ 
        radius = 6 
        for (stop in this) { 
                    this[stop].stop() 
        } 
} 

onClipEvent(enterFrame){ 
        if(Key.isDown(Key.UP)){ 
                    this._y -= speed 
                    facing = "up" 
        } 
        if(Key.isDown(Key.DOWN)){ 
                    this._y += speed 
                    facing = "down" 
        } 
        if(Key.isDown(Key.RIGHT)){ 
                    this._x += speed 
                    facing = "right" 
        } 
        if(Key.isDown(Key.LEFT)){ 
                    this._x -= speed 
                    facing = "left" 
        } 
        if(Key.isDown(Key.SHIFT)){ 
                    speed = 5 
                    state = "run" 
        }else{ 
                    speed = 3 
                    state = "walk" 
        } 
        if(!Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)){ 
                    this[facing].gotoAndStop(1) 
        }else{ 
                    this[facing].play() 
        } 
        while(_root.walls.hitTest(_x, _y+radius/2, true)){ 
                    _y--; 
        } 
        while(_root.walls.hitTest(_x, _y-radius, true)){ 
                    _y++; 
        } 
        while(_root.walls.hitTest(_x-radius, _y, true)){ 
                    _x++; 
        } 
        while(_root.walls.hitTest(_x+radius, _y, true)){ 
                    _x--; 
        } 
        gotoAndStop(state+facing) 
        depthControl() 
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-27 09:19:28

hitTest无法从瓶子中直接识别位图中的alpha,但我认为如果您修改BitmapData类,就不可能找到解决方案。一种更容易(但不那么优雅)的方法是使用不可战胜的图层,您只需填写玩家无法到达的位置,并对此进行hitTest,而不是包含png的剪辑。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23552981

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档