[Gambas-user] Array of Runtime Objects
Fabien Bodard
abidoo.too at ...11...
Sun Jan 11 21:06:06 CET 2004
Le Dimanche 11 Janvier 2004 18:09, -=FoX=- a écrit :
> Hi :-D
>
> There is a panel, with a button "ADD" and a button "REMOVELAST"
> When I click "ADD", I add to my object array a new object and a new
> object appear under the 2 buttons. Think playcards...
> When I click "REMOVELAST", I call a Playcard sub that delete the
> principal panel of the playcard and then resize the array ( - 1 object)
> And is *ALL* ok. :)
>
> Suppose that every playcard have a button "KILLME" that kill itself.
> ---- ---- ---- ----
>
> | 0 | | 1 | | 2 | | 3 |
>
> ---- ---- ---- ----
> Suppose also that i want remove the card nuumber "2"
> ---- ---- ----
>
> | 0 | | 1 | | 3 |
>
> ---- ---- ----
>
> Now, the question:
> can I raise a main event from a playcard event?
> The "KILLME" clik launch the sub "destroycard" in the main window.
> In the main i have a sub that kill the objecr card2 and remove array[2]
> then i have a sub that refresh the cards position
>
> In alternative, i make a timer in main window, that check if the
> variable "alive" of every card is 1 or zero.
> When i click "KILLME" i set alive to 0 and so the timer call the sub
> that destroy the card.
> Then i must to refresh the array to remove the "hole" :D
>
> I don't like the second way :/
> Any idea?
>
> Thanks in advance
>
Hi
...
I don't really understand...
First why don't you use a collection in place of the array
It's more simple to refresh and have not black when you delete a play card (or
maby you game workspace work like a grid... in this case array is better).
and for the event... Have a look at Panel_Delete()
And When you create a new panel give a value to the Tag properti of yhe new
panel
MyPanel = New Panel(Me) as MyPanel
ArPanel.Add(MyPanel)
MyPanel.Tag = ArPanel.Count
MyPanel.Move (12,13,25,50)
MyPanel.Visible = true
public Sub Button_Remove()
ArPanel[2].Delete
End
Public Sub MyPanel_Delete()
RefreshCards()
End If
Fabien
More information about the User
mailing list