forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   BlitzMax (http://forum.boolean.name/forumdisplay.php?f=104)
-   -   Получить значение по индексу (http://forum.boolean.name/showthread.php?t=7362)

snikers 22.11.2008 15:35

Получить значение по индексу
 
Ищо одну проблемко :(

Код:

Type TMusicBox
        Field list:TList
       
        Function Create:TMusicBox()
                Local mb:TMusicBox = New TMusicBox
                If (mb.list = Null) Then mb.list = CreateList()
                Return mb
        End Function
       
        Method Add(filename$)
                Local mt:TMusicTrack = TMusicTrack.Create(filename)
                list.AddLast(mt)
                mt = Null
        End Method
       
        Method Play(num%)
                If (num > 0 And num <= list.Count())
                        For Local m:TMusicTrack = EachIn list
                                If Not(m.IsPlaying()) m.Play()
                        Next
                End If
        End Method
       
        Method PlayRandom()
                'Local r% = Rand(0, list.Count())
                'If (list.Contains(r))
                '        list.ValueAtIndex(r).Play()
                'End If
        End Method
End Type

есть список, в нем TMusicTrack'ы, есть метод Play(num%) который должен играть num из списка, подскажите как такое сделать :rolleyes: И еще обясните для чего нужен TLink?

Код:

Type TMusicTrack
        Field audiofile%, channel%
        Field pitch%, volume#, pan#
       
        Function Create:TMusicTrack(filename$)
                Local mt:TMusicTrack = New TMusicTrack
                mt.audiofile = bbLoadSound(filename)
                mt.volume = 1
                mt.pitch = 44000
                mt.pan = 0
                Return mt
        End Function
       
        Method Delete()
                If (audiofile) Then bbFreeSound(audiofile)
        End Method
       
        Method Play()
                channel = bbPlaySound(audiofile)
        End Method
       
        Method Stop()
                If (channel <> 0)
                        bbStopChannel(channel)
                End If
        End Method
       
        Method Pause()
                If (channel <> 0)
                        bbPauseChannel(channel)
                End If
        End Method
       
        Method Resume()
                If (channel <> 0)
                        bbResumeChannel(channel)
                End If
        End Method
       
        Method SetVolume(value#)
                If (channel <> 0)
                        If (value > 0 And value < 1) Then volume = value
                        bbChannelVolume(channel, volume)
                End If
        End Method
       
        Method GetVolume#()
                Return volume
        End Method
       
        Method SetPitch(value%)
                If (channel <> 0)
                        If (value > 8000 And value < 44000) Then pitch = value
                        bbChannelPitch(channel, pitch)
                End If
        End Method
       
        Method GetPitch%()
                Return pitch
        End Method
       
        Method SetPan(value#)
                If (channel <> 0)
                        If (value >= - 1 And value <= 1) Then pan = value
                        bbChannelPan(channel, pan)
                End If
        End Method
       
        Method GetPan#()
                Return pan
        End Method
       
        Method IsPlaying%()
                If (channel <> 0)
                        Return bbChannelPlaying(channel)
                End If
        End Method
End Type


dimanche13 22.11.2008 17:52

Ответ: Получить значение по индексу
 
ну дык:
Код:

TMusicTrack(list.ValueAtIndex( num )).play()

snikers 22.11.2008 18:49

Ответ: Получить значение по индексу
 
крутЪ! спасибо, только можеш обяснить как ета конструкция работает, тоесть что означает TMusicTrack(c параметрами внутри)?

jimon 22.11.2008 19:18

Ответ: Получить значение по индексу
 
snikers
приведение типов
Код:

a:float = 0
b:int = int(a)


snikers 22.11.2008 19:24

Ответ: Получить значение по индексу
 
еще раз крутЪ! я думал конвертировать можно только стандартные типы даных, ето же открывает большие возможности, и как я раньше об этом не знал..


Часовой пояс GMT +4, время: 12:24.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Перевод: zCarot