|
texture - texture handle u_speed# - horizontal movement in texture tiles per second v_speed# - vertical movement in texture tiles per second |
|
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. See also: PauseTextureScroll, PositionTexture, ScaleTexture, RotateTexture, LightCookie, ShaderTexture. |
; TextureScroll Example
; ---------------------
Graphics3D 640,480,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
; A conveyor belt built from two triangles, UV-tiled four times
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
; Draw a striped belt tile into an ordinary texture
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
; Start the belt moving using elapsed time - no UpdateWorld needed
speed#=0.3
TextureScroll texture,0,speed
paused=False
While Not KeyDown(1)
; Space pauses, [ / ] change speed, R resets the reached offset
If KeyHit(57)
paused=Not paused
PauseTextureScroll texture,paused
EndIf
If KeyHit(26)
speed=speed-0.1
TextureScroll texture,0,speed
EndIf
If KeyHit(27)
speed=speed+0.1
TextureScroll texture,0,speed
EndIf
If KeyHit(19) Then PositionTexture texture,0,0
; Arrow keys move the camera
If KeyDown(200) Then MoveEntity camera,0,0,0.1
If KeyDown(208) Then MoveEntity camera,0,0,-0.1
If KeyDown(203) Then TurnEntity camera,0,1,0
If KeyDown(205) Then TurnEntity camera,0,-1,0
RenderWorld
Color 240,240,240
Text 0,0,"Arrow keys: move camera Space: pause [ / ] : speed R: reset Esc: exit"
Text 0,20,"TextureScroll texture,0,"+speed+" paused: "+paused
Flip
Wend
End