Implement text scrolling in Director

zhaozj2021-02-17  41

I have recently asked me how to implement text scrolling effect in DR. I only gave some tips. I think this problem is a simpler, but asking, there is more Awareness of this problem is quite a lot (you are a little bit of this question), and later I want to find a typical example to discuss this problem with my friends, and I found the following. This behavior is discovered. Make my understanding of this question deeper steps (inside still have a lot of skill), I also got a new behavior written thinking approach from the following programs, and it also applied in other respects. Here is this program, I have made some simple comments:

Property PMEM

Property Pimage

Property Pscroll

Property PWIDTH, PHEIGHT

Property PvisibleHeight

Property PBACKGROUNDCOLOR

### Define this behavior attribute setting ###

On getPropertyDescriptionList ME

List = [:]

Addprop List, #PVisibleHeight, [#comment: "visible height", #format: #integer, #default: 100]

Return List

end

On Beginsprite ME

n Get the size of the Text MEMBER

PWIDTH = Sprite (me.spritenum) .member.width

PHEIGHT = Sprite (me.spritenum) .member.height

N get the size of the text image

PIMAGE = duplicate (sprite (me.spritenum) .member.image)

PBACKGROUNDCOLOR = Sprite (me.spritenum) .member.bgcolor

n Create a new bitmap for us to use

PMEM = New (#bitmap)

PMem.image = Image (pWidth, Pheight, 32)

PMem.Regpoint = Point (0, 0)

Sprite (me.spritenum) .member = PMEM

n Implement image scroll from the lower

Pscroll = -pvisibleheight

SETIMAGE (ME)

end

ON setImage me

n Use the fill command to make the image full of background colors

PMem.Image.Fill (Rect (0, 0, Pwidth, PvisibleHeight), PBackgroundColor

n Place an image to the corresponding position

PMem.image.copypixels (Pimage, Rect (0, 0, Pwidth, PvisibleHeight), Rect (0, Pscroll, PWIDTH, PVISIBLEHEIGHT PSCROLL)

end

ON EXITFRAME ME

n Set the speed of scrolling is a pixel

Pscroll = pscroll 1

n If scrolling text is over, design a loop here

IF pscroll> Pheight Then Pscroll = -pvisibleheight

SETIMAGE (ME)

end

On EndSprite ME

ERASE PMEM

end

This behavior is more convenient than my previous method, and I will introduce this basic writing idea. If you are very familiar with Lingo, you can see it through the above procedures, I will say this again. Luo Tao. But I still want to say my experience (really unhappy!) The biggest feature of this behavior is to save space, as long as a score is OK. There is also a clever usage to use the fill command so that the old image is erased when moving the text image.

转载请注明原文地址:https://www.9cbs.com/read-28889.html

New Post(0)