我查了一下你的參考遊戲,明白你的意思是「2.5D」。根據我的理解,解決此問題的最佳方法是通過變換對象的x,y座標來創建僞三維。你會有一個功能爲你做轉換,這裏是我對一個例子的最好猜測。
// This function takes in a x- and y-coordinates of an object corner and returns the
// coordinates of the corresponding back corner of an object.
var transform = function(x,y) {
// The farther the character is from the object, the more skew there would be.
// Here "char" is your globally recognized game character. If it was not in the scope
// of the function you'd have to pass it as a parameter.
var skew = (char.x > x) ? (char.x - x) : (x - char.x);
var newx = (skew * 0.1); // obviously this would be variable depending on your liking
// If the object corner is not on the ground (y == 0) then subtract from it's value,
// otherwise add.
var newy = (y > 0) ? (y - 10) : (y + 10);
};
在我的例子10
是距離單位來改變該量y座標。這就是你的示例遊戲所做的。希望我的輸入幫助,
里根
謝謝你,我一定會看看這些引擎作爲一種形式的靈感。 – clicheName 2012-07-15 10:35:22