TextureScroll texture,u_speed#,v_speed#
Parameters
|
texture - texture handle u_speed# - horizontal movement in texture tiles per second v_speed# - vertical movement in texture tiles per second |
Description
|
Automatically moves a texture using elapsed time. This is useful for conveyor belts, drifting clouds and scrolling energy patterns. Positive and negative speeds use the same directions as PositionTexture. For example, a U speed of 0.25 moves one tile in four seconds. Both speeds start at zero. Changing speed preserves the reached position. Setting both to zero stops there. PauseTextureScroll freezes movement while remembering its speed. Movement continues without UpdateWorld; pause texture scrolling separately when pausing your game. PositionTexture sets the current offset immediately and movement continues from that position. ScaleTexture, RotateTexture and TextureCoords still apply. Entities sharing this texture share its movement; load or create separate textures for independent movement. Repeat addressing stays smooth over long runs. Clamped axes keep moving beyond the image edge and never wrap. The command changes the existing texture transform. It works with classic materials, Standard's UV maps, including its higher named maps, and shader inputs that use the texture transform helper. Existing ShaderTexture bindings update live. A shader using raw UVs or deliberate world/screen mapping chooses its own coordinates. Higher named texture roles still require the corresponding shader metadata support; do not assume every map scrolls. This command does not assign a shader or change TextureBlend. Light cookie projections bound with LightCookie also follow the moving transform. All cameras and shadows submitted before Flip share a sampled movement time. Canvas views submitted together before presentation also share it. Velocity and pause state are transient; set them again after loading a world. Requires Extended mode. See also: PauseTextureScroll, PositionTexture, ScaleTexture, RotateTexture, LightCookie, ShaderTexture. |
Example
; Extended mode: automatic texture movement on an ordinary classic material. Graphics3D 800,600,0,2 SetBuffer BackBuffer() camera=CreateCamera():PositionEntity camera,0,3,-4:RotateEntity camera,25,0,0 CameraClsColor camera,18,23,31 light=CreateLight():RotateEntity light,55,-35,0 belt=CreateMesh():surface=CreateSurface(belt) AddVertex surface,-2,0,0,0,0:AddVertex surface,2,0,0,1,0 AddVertex surface,2,0,7,1,4:AddVertex surface,-2,0,7,0,4 AddTriangle surface,0,2,1:AddTriangle surface,0,3,2:UpdateNormals belt texture=CreateTexture(64,64,1) SetBuffer TextureBuffer(texture):ClsColor 35,65,75:Cls Color 220,175,55:Rect 0,0,64,12:Color 130,145,150:Rect 0,12,64,3 SetBuffer BackBuffer():EntityTexture belt,texture speed#=.3:TextureScroll texture,0,speed While Not KeyDown(1) If KeyHit(57) Then paused=Not paused:PauseTextureScroll texture,paused If KeyHit(200) Then speed=speed+.1:TextureScroll texture,0,speed If KeyHit(208) Then speed=speed-.1:TextureScroll texture,0,speed If KeyHit(19) Then PositionTexture texture,0,0 RenderWorld Color 240,240,240 Text 12,12,"Space: pause/resume | Up/Down: speed | R: reset offset | Esc: exit" Text 12,34,"Tiles/second: "+speed+" Paused: "+paused Flip Wend End
Index