我一直在这里学习本教程- 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代码:
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()
}发布于 2014-05-27 09:19:28
hitTest无法从瓶子中直接识别位图中的alpha,但我认为如果您修改BitmapData类,就不可能找到解决方案。一种更容易(但不那么优雅)的方法是使用不可战胜的图层,您只需填写玩家无法到达的位置,并对此进行hitTest,而不是包含png的剪辑。
https://stackoverflow.com/questions/23552981
复制相似问题