2014-05-08 21 views
0

我在这里已经按照本教程 - http://www.stormation.info/rpg-game-creation-tutorial/在Flash(AS2)中带有字符冲突的PNG图像....如何?

我试图做一个简单的塞尔达风格的RPG游戏,但在本教程中它采用了动态背景。我想使用PNG图像,这些图像具有角色可以漫游的透明区域。

像这些: http://www.imagebam.com/image/de39a1325517813

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

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

我想从透明区域分开的一切来阻止字符。这可能吗?

本教程有碰撞检测,但是当我通过将png作为影片剪辑关注它,然后使用实例“墙”来对应代码时,我的角色在测试场景时消失。

这是我目前的As 2的代码:

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() 
} 

回答

0

则hitTest无法识别位图阿尔法直出瓶,但我不认为这是不可能拿出如果一个解决方案修补BitmapData类。一个更容易(但不太优雅)的方法是使用一个无敌的图层,在那里你只需填写玩家不能去的地方,并且用hitTest来代替包含png的剪辑。

相关问题