gol-a-khung   01-14-2016, 10:18 AM
#5
Event: Create: ให้กำหนดตัวแปร
Code:
i= 0; // ตัวแปรกำหนดค่าวนลูป
e= 0; // ตัวแปรเก็บค่ากำหนดตำแหน่งอเรย์
enemy[0]= obj_ศัตรูตัวที่ 1
enemy[1]= obj_ศัตรูตัวที่ 2
enemy[2]= obj_ศัตรูตัวที่ 3
enemy[3]= obj_ศัตรูตัวที่ 4
enemy[4]= obj_ศัตรูตัวที่ 5
enemy[5]= obj_ศัตรูตัวที่ 6
enemy[6]= obj_ศัตรูตัวที่ 7  // อเรย์ที่เก็บออปเจ็กต์ศัตรูไว้

Event: Step: ใส่โค้ด
Code:
for(i=0; i<6; i+=1;){
instance_create(x,y,enemy[e]); //คำสั่งสร้างตัวศัตรู
e+= 1;
}
ศัตรูที่เกิดจะไม่ซ้ำกันตามที่ได้กำหนดครับ แต่จะเกิดจุดเดียวกันเพราะไม่ได้กำหนดตำแหน่ง X และ Y ครับ
This post was last modified: 01-19-2016, 10:06 AM by gol-a-khung.
  
Users browsing this thread: 1 Guest(s)
Powered By MyBB, © 2002-2024 MyBB Group.
Made with by Curves UI.