Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, 7th_zorro, ozgur, Quad), 841 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Wie kann man eine View Entity anklicken? #487901
11/05/23 19:26
11/05/23 19:26
Joined: Jan 2016
Posts: 9
C
ColeFoster Offline OP
Newbie
ColeFoster  Offline OP
Newbie
C

Joined: Jan 2016
Posts: 9
Hallo zusammen, ich habe noch die gamestudio A7 und möchte ein 2d Adventure mittels wed kreieren. Ich benutze als Räume eine TGA Grafik als view Entity. Soweit so gut. Nun möchte ich eine zweite View entity mit einem höheren Layer als anclickbares Objekt darüber legen wie z. B. Eine Tür oder Gegenstand. Das geht auch das Problem dabei ist, dass die art von Entity nicht anklickbar ist. Ich habe versucht über eine Funktion enable click und dann dass event dazu zu schreiben. Es gibt keine Fehlermeldung aber beim anklicken tut sich einfach nichts.
Bin gespannt ob es dafür eine Lösung gibt. Danke schon einmal im voraus.

Re: Wie kann man eine View Entity anklicken? [Re: ColeFoster] #487906
11/06/23 19:21
11/06/23 19:21
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Hallo.
Ich persönlich würde Dir von view ents abraten.

So weit ich weiss ist bei view ents auch die XYZ Position Auflösungsabhängig.
Ich benutze aber nie View ents muss ich dazu sagen, weiss aber das die sich nicht so einfach anklicken lassen.

Ich würde Dir empfehlen das ohne View ents aufzubauen.
Dann bist Du auch nicht von der Auflösung abhängig und hast meiner Meinung nach nur Vorteile.

Ich habe Dir hier ein Beispiel verfasst wie Du das gleiche ohne View ents bauen könntest:
Code
// example needs:
// backgr1.tga = 1024x768 background image
// backgr2.tga = same
// door1.tga   = a door image
// door2.tga   = same
// cursor.tga  = mouse cursor
BMAP* bmap_arrow = "cursor.tga"; // mouse cursor bitmap

ENTITY* your_background;         // pointer to your used background image 1024x768 in this example
ENTITY* your_door_ent;           // pointer to your door image (any size)


void your_background_ent_event_1(){ // first example event for your background
   if (event_type == EVENT_CLICK){
      printf ("You clicked the background");
   }			
}
void your_background_ent_event_2(){ // second example event for your background room 2
   if (event_type == EVENT_CLICK){
      printf ("You clicked the background in room2");
   }			
}


void your_door_ent_event_1(){      // first example event for your door
   if (event_type == EVENT_CLICK){
      printf ("You clicked the door entity");
   }			
}
void your_door_ent_event_2(){      // second example event for your door in room2
   if (event_type == EVENT_CLICK){
      printf ("You clicked the door entity in room2");
   }			
}

// load the background and the door and give them click events
void init_level_screen1(){
   your_background = ent_create ("backgr1.tga", vector (880,0,0), NULL); // 1024x768 background image for example fills screen at this position
   if (your_background){
      your_background.emask |= ENABLE_CLICK;
      your_background.event = your_background_ent_event_1;
   }	
   your_door_ent = ent_create ("door1.tga", vector (879,0,0), NULL); // in front of the background image
   if (your_door_ent){
      your_door_ent.emask |= ENABLE_CLICK;  
      your_door_ent.event = your_door_ent_event_1;	     
   }
} 

// example how you could switch to another room
void init_next_room (roomnr){
    if (roomnr == 2){
       if (your_background){
          ent_morph (your_background, "backgr2.tga");		
	  your_background.event = your_background_ent_event_2;
      }
      if (your_door_ent){
         //your_door_ent.y = 100;
         //your_door_ent.z = 50;
         ent_morph (your_door_ent, "door2.tga");		
         your_door_ent.event = your_door_ent_event_2;
      }
   }
}

var room_active = 1;

// press enter to switch to room nr2 for example
void main(){ 
   video_mode = 7;
   video_screen = 2;
   level_load (NULL); // or a empty wmb file
  
   init_level_screen1();
    
   mouse_map = bmap_arrow;  
   mouse_mode = 4;       
  
   while (1){
      if (key_enter){
         if (room_active == 1){
            room_active += 1;
            init_next_room (room_active); //change background and the door image for next room now           
         }
      }	
      wait (1);
   }
}

Das Beispiel lädt eine Hintergrundgrafik und platziert eine Türgrafik darauf. Mit der Enter Taste kannst Du in den zweiten Raum wechseln.

Das script als main.c speichern und ausführen. backgr1.tga(1024x768), backgr2.tga, door1.tga, door2.tga und cursor.tga dazu.
Wenn Du für die Backgrounds eine andere Auflösung willst als 1024x768, musst Du einfach nur den X Wert (880) anpassen, solange bis das Image das Fenster wieder füllt.

Das Beispiel ermöglicht nun auch scrollen (z.B. per camera.yz) oder zoomen (z.B. per camera.arc oder camera.x).


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Wie kann man eine View Entity anklicken? [Re: rayp] #487908
11/07/23 16:52
11/07/23 16:52
Joined: Jan 2016
Posts: 9
C
ColeFoster Offline OP
Newbie
ColeFoster  Offline OP
Newbie
C

Joined: Jan 2016
Posts: 9
Hallo, danke für die Antwort.
Nein bei View Entitys sind die xyz Positionen nicht Auflösungsabhängig und behalten auch ihre Größe bei.

Void habe ich noch nie etwas gemacht, denke aber das es ein guter Weg ist den du mir da geschrieben hast.Werde ich auf jeden Fall mal ausprobieren.

Re: Wie kann man eine View Entity anklicken? [Re: ColeFoster] #487909
11/07/23 18:05
11/07/23 18:05
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Anstelle von void kannst Du auch function schreiben.


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1