ImranRayan1 @garten_of_Rayan_
var game_title = "عنوان اللعبة"
func _ready():
# إنشاء عنصر زر لبدء اللعبة
var start_button = Button.new()
start_button.text = "ابدأ اللعبة"
start_button.connect("pressed", self, "_on_start_button_pressed")
# تحديد الخصائص الخاصة بعنصر الزر
start_button.rect_min_size = Vector2(200, 50)
start_button.rect_pivot_offset = Vector2(0.5, 0.5)
# إضافة عنصر الزر إلى القائمة
add_child(start_button)
# إعداد محور الزر في الوسط العمودي والأفقي
set_anchors_and_margins(start_button, Vector2(0.5, 0.5), Vector2(0.5, 0.5))
start_button.rect_position = Vector2(0, -50)
# إنشاء عنصر زر لإيقاف اللعبة
var stop_button = Button.new()
stop_button.text = "إيقاف اللعبة"
stop_button.connect("pressed", self, "_on_stop_button_pressed")
# تحديد الخصائص الخاصة بعنصر الزر
stop_button.rect_min_size = Vector2(200, 50)
stop_button.rect_pivot_offset = Vector2(0.5, 0.5)
# إضافة عنصر الزر إلى القائمة
add_child(stop_button)
# إعداد محور الزر في الوسط العمودي والأفقي
set_anchors_and_margins(stop_button, Vector2(0.5, 0.5), Vector2(0.5, 0.5))
stop_button.rect_position = Vector2(0, 50)
func _on_start_button_pressed():
# يتم طباعة رسالة عند النقر على زر بدء اللعبة
print("بدء اللعبة")
func _on_stop_button_pressed():
# يتم طباعة رسالة عند النقر على زر إيقاف اللعبة
print("إيقاف اللعبة")
# دالة لتعيين محاذاة العنصر والهوامش
func set_anchors_and_margins(node, anchor_position, margin_position):
node.rect_anchor_min = anchor_position
node.rect_anchor_max = anchor_position
node.rect_min_size = node.rect_size
node.rect_pivot_offset = margin_position
