|
Question about Entity flags
#323108
05/11/10 17:26
05/11/10 17:26
|
Joined: Apr 2010
Posts: 56
Badrizmo
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 56
|
I was hoping to understand the difference between using the following approaches in showing/hiding and Entity Approach #1 if (CamMode == ThirdPersonCamera) { Badrizmo.flags2 |=VISIBLE; } else { Badrizmo.flags2 &= ~VISIBLE; // Fails to hide the player }
Approach #2 if (CamMode == ThirdPersonCamera) { set(Badrizmo,VISIBLE);// Fails to show the player} else { set(Badrizmo,INVISIBLE); } Thanks in advance
|
|
|
Re: Question about Entity flags
[Re: Badrizmo]
#323111
05/11/10 17:42
05/11/10 17:42
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
It is the same. The second one is a "#define macro"
#define set(obj,flag) obj.flags |= (flag) #define reset(obj,flag) obj.flags &= ~(flag)
search for define in the manual
PS: set(Badrizmo,INVISIBLE); is false, use: reset(Badrizmo,VISIBLE); INVISIBLE is another flag...
Last edited by Widi; 05/11/10 17:42.
|
|
|
Re: Question about Entity flags
[Re: Widi]
#323281
05/12/10 21:11
05/12/10 21:11
|
Joined: Apr 2010
Posts: 56
Badrizmo
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 56
|
Okay, I wrote this simple (but complete) test code. but to my shock the entity was never hidden. I just want to know what did I do wrong. I'm sure I have assigned my action to a model because when I press F7 the model is moved by 20 quants as you will see later in code. #include <acknex.h> #include <default.c>
ENTITY* Badrizmo;
var ShowHideFlag = 0; function ShowHideBadrizmo () { if (ShowHideFlag == 0) { //Hide the entity Badrizmo.flags &=~VISIBLE; Badrizmo.x +=20; ShowHideFlag = 1; } else { //Show the entity Badrizmo.flags |= VISIBLE; ShowHideFlag = 0; } }
function main() { level_load("shop.wmb"); wait (2); on_f7 = ShowHideBadrizmo; }
action move() { Badrizmo = me; while (1) { if(key_w) { c_move(me,vector(5*time_step,0,0),nullvector, GLIDE); } if(key_s) { c_move(me,vector(5* -time_step,0,0),nullvector, GLIDE); } if(key_a) { me.pan +=4*time_step; } if(key_d) { me.pan -=4*time_step; } wait(1); } }
when I replaced Badrizmo.flags &=~VISIBLE; by Badrizmo.flags &=~INVISIBLE; and Badrizmo.flags |= VISIBLE; by Badrizmo.flags |= INVISIBLE; it worked fine and I was toggoleing between hidden and visible by F7, I need to know why did the original code didn't work (the one utilizing the VISIBLE flag). Thanks in advance for your valuable help.
|
|
|
|