wenwen
wenwen

探索網路世界和進入區塊鏈的過程或許很平凡,但我就是想分享給大家,若能幫助到有需要幫助的人,那就更好了。 有幫到你的話,記得按下方拍手圖,不需花你任何金錢,免費註冊Liker ID,就可對我化讚為賞:https://button.like.co/willie5068

031第12章 A SHIP THAT FIRES BULLETS_續8_super().init()

進度雖慢,但貴於持之以恆。

💛20230131 晨讀感言:

💔若 建置一個 類(Class) 有 繼承 另一個 modual 時,除了 在 此類的 `__init__()` 裡需要 利用 super().init() 來 引用 modual 的 `__init__` 之外,最重要的是,此類(class)的 `__init__()` 的括號內,通常會 搭配 主程式 某個類的 instane 當作 它的 參數(parameter) 來使用,而在 主程式 某個類中 呼叫此 Class 時,則會用 Class(self) 來調用,注意, 這裡的 self 就是主程式 某個類的 instance。

💔 發現在寫遊戲程式時,只要有涉及到 要在 螢幕 上 展現的 元素(像是 螢幕大小範圍,飛船,發射的子彈 等)在建置這些類時,都會 improt pygame。

💛晨讀摘要:

💚247 The Bullet class inherits from Sprite, which we import from the pygame sprite module. When you use sprites, you can group related elements in your game and act on all the grouped elements at once. To create a bullet instance, `__init__()` needs the current instance of AlienInvasion, and we call super() to inherit properly from Sprite. We also set attributes for the screen and settings objects, and for the bullet’s color.

from:《python crash course》

CC BY-NC-ND 2.0 版权声明

喜欢我的文章吗?
别忘了给点支持与赞赏,让我知道创作的路上有你陪伴。

加载中…
加载中…

发布评论