2012-02-17 67 views
0

遇到問題試圖滾動的BitmapData放在這裏半像素是我的原代碼AS3 BitmapData複製像素半像素?

var speed:Number = 1; 
_bitmapData.copyPixels(_backgroundParallax, _screenRect, _zeroPoint, null, null, true); 
_backgroundParallax.copyPixels(_backgroundParallax, new Rectangle(0, 0, speed, _backgroundParallax.height), new Point(_backgroundParallax.width-speed,0), null, null, false); 
_backgroundParallax.scroll((speed*-1) , 0); 

其工作,直到我改變變種速度爲0.5,這是因爲.scroll方法希望廉政局的,所以我複製哪些滾動在做嘗試,並允許0.5像素

var speed:Number = 1; 
_bitmapData.copyPixels(_backgroundParallax, _screenRect, _zeroPoint, null, null, true); 
_backgroundParallax.copyPixels(_backgroundParallax, new Rectangle(0, 0, speed, _backgroundParallax.height), new Point(_backgroundParallax.width-speed,0), null, null, false); 
_backgroundParallax.copyPixels(_backgroundParallax, new Rectangle(0, 0, _backgroundParallax.width, _backgroundParallax.height), new Point((speed*-1),0), null, null, false); 

這又偉大工程的時候,速度是1,但同樣都當它被設置爲0.5

任何想法不動?

+1

不幸的是,像素沒有一半大小完整下載的源代碼。也許你可以用一些數學來減慢速度。 – 2012-02-17 10:30:21

+0

您是否嘗試多次調用此代碼來滾動位圖,但想要降低執行速度? – sch 2012-02-17 11:00:26

+0

@sch這個代碼是在enterframe上運行的 – rorypicko 2012-02-17 11:08:14

回答

1

使用您使用的方法將無法平滑地進行半像素滾動。但是我已經開發了兩種使用變換矩陣的替代方案,這些方法非常好。

這裏有兩種不同的方法來滾動:

這種方法滾動一個單個圖像到它的極限。 http://plasticsturgeon.com/2010/11/super-fast-scrolling-of-huge-bitmaps/

此方法無限制地滾動平鋪的圖像。 http://plasticsturgeon.com/2010/06/infinite-scrolling-bitmap-backgrounds-in-as3/

工作演示,解釋和提供的鏈接