Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Akow, 1 invisible), 1,499 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
entity doesn't react to mousepointer #138611
06/28/07 14:21
06/28/07 14:21
Joined: Jul 2004
Posts: 52
Vienna
H
Hawk Offline OP
Junior Member
Hawk  Offline OP
Junior Member
H

Joined: Jul 2004
Posts: 52
Vienna
Hi, i have some 3d objects on my screen which should react when the mousepointer touches them. It works fine with all entities in the level, but i have problems with those which are only on screen.

like this one, I have defined the entity: Code:
   
entity INV_kaffeebecher
{
type="kaffeebecher.mdl";
view=top_view;
layer=2;
x=20;
y=9.74;
z=-7.4;
roll=2;
tilt=12;
scale_x=0.05;
scale_y=0.05;
scale_z=0.05;
flags= visible;
}


The following function is called in the mainfunction.Code:

function item_kaffee()
{
INV_kaffeebecher.enable_touch=on;
INV_kaffeebecher.enable_release=on;
INV_kaffeebecher.enable_click=on;
INV_kaffeebecher.event=reaktion_kaffeebecher;
while(1)
{
INV_kaffeebecher.pan += 5*time;
INV_kaffeebecher.pan %= 360;
wait(1);
}
}



I have no errors, and the entity is rotating. So the function works, but it doesn't react to touch, release and click. Of course I have a function to tell the engine what should happen like this way.Code:

function reaktion_kaffeebecher()
{
if(event_type == event_touch)
{ INV_kaffeebecher.visible = off;
}
if....
...}


but nothing happens. Do you have an idea?


Commcercial A6.60
Re: entity doesn't react to mousepointer [Re: Hawk] #138612
06/28/07 14:53
06/28/07 14:53
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
but what about the mouse code?
should looks like:

Code:

starter mouse_function
{
mouse_mode = 1;
enable_mouse = ON;
mouse_range = 10000;
mouse_map = some_bmp;
while(1)
{
mouse_pos.x = pointer.x; mouse_pos.y = pointer.y;
wait(1);
}
}



Last edited by tompo; 06/28/07 14:54.
Re: entity doesn't react to mousepointer [Re: tompo] #138613
06/28/07 15:39
06/28/07 15:39
Joined: Jul 2004
Posts: 52
Vienna
H
Hawk Offline OP
Junior Member
Hawk  Offline OP
Junior Member
H

Joined: Jul 2004
Posts: 52
Vienna
my mousecode looks like this:
mouse_map = mouse_pcx;
enable_mouse = ON;
mouse_mode=2;
mouse_range=2000;
while(1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait(1);
}

i tried it also with a range of 100000 and mouse_mode=1, but no difference.


Commcercial A6.60
Re: entity doesn't react to mousepointer [Re: Hawk] #138614
06/28/07 15:49
06/28/07 15:49
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
maybe better use simple
entity* INV_kaffeebecher;

then
my_action
{
INV_kaffeebecher = me;
my.enable_touch=on;
my.enable_release=on;
my.event = reaktion_kaffeebecher;
}

and try to change:
my.visible = off;
to:
my.invisible = on;


Never say never.
Re: entity doesn't react to mousepointer [Re: tompo] #138615
06/28/07 17:35
06/28/07 17:35
Joined: Jul 2004
Posts: 52
Vienna
H
Hawk Offline OP
Junior Member
Hawk  Offline OP
Junior Member
H

Joined: Jul 2004
Posts: 52
Vienna
ok that should work, because thats how i do it with the other entities.
but this time, i want to stay the entity all the time at the same position on the screen.

in fact i want the following...after the player has bought a cup of coffee a 3d object that looks like a cup of coffee appears in the inventory. if the player now moves the cursor over the coffee cup it should rotate. if he releases it, the cup stops rotating and just stands still in the inventory. if the player clicks on the cup, it should become larger and be sticky at the cursour coordinates.

i will try it out with ent_create

edit:
i can't manage to convert the 3d coordinates to 2d coordinates.
vec_set(slot1,vector(20,9.74,-7.4));
vec_to_screen(slot1,top_view);
ent_create("kaffeebecher.mdl",slot1,item_kaffee);

i thought that would work but it doesnt. i dont want the cup to be created somewhere in the 3d world, but on the 2d screen.

Last edited by Hawk; 06/28/07 19:56.

Commcercial A6.60
Re: entity doesn't react to mousepointer [Re: Hawk] #138616
06/29/07 14:05
06/29/07 14:05
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
slot1 is the panel?
if yes.. try this (not tested)

but I'm not sure is this what U want to do

Code:
 
entity* cofee_ent;
define holding,skill1;
in some function
{
ent_create("kaffeebecher.mdl",nullvector,item_kaffee);
}

function cofee_event
{
if(event_type == event_click)
{
my.scale_x = 2;
my.holding =1;
}
else
{
my.holding =0;
my.scale_x = 1;
if(event_type == event_touch)
{
my.pan += 5* time_step;
}
if(event_type == event_release)
{
my.pan += 0;
}
}
}

function item_kaffee
{
cofee_ent = me;
my.enable_touch = on;
my.enable_release = on;
my.ENABLE_click = ON;
my.event = cofee_event;
while(me)
{
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
if(my.holding == 1) && (mouse_left ==1)
{
temp.x = mouse_pos.x; temp.y = mouse_pos.y temp.z = 50; //cofee at mouse position
}
if(my.holding == 0)
{
temp.x = slot1.x; temp.y = slot2.y temp.z = 50; //cofee at slot position
}
vec_for_screen(temp,camera);
vec_set(my.x, temp); //cofee will be always 50 quants front of camera
wait(1);
}
}



Last edited by tompo; 06/29/07 14:34.

Never say never.
Re: entity doesn't react to mousepointer [Re: tompo] #138617
06/29/07 14:55
06/29/07 14:55
Joined: Jul 2004
Posts: 52
Vienna
H
Hawk Offline OP
Junior Member
Hawk  Offline OP
Junior Member
H

Joined: Jul 2004
Posts: 52
Vienna
okay thats not what I wanted, but it almost comes up to my expectations.
I use your script now, but edited it a bit. I don't use an extra panel. To get the position I use the interface panel which is at 0,0 and add the numbers I need to get the right position. But I have another problem now. The interface is at layer 1 and hides the cup. How can I influence the layer of the entity? I think "layer=2;" doesn't work here because it's not a panel or text.

thank you so far for your help!


Commcercial A6.60
Re: entity doesn't react to mousepointer [Re: Hawk] #138618
06/29/07 15:05
06/29/07 15:05
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
You can't
It's imposible to place panel behind the entity so far
Try set panel's layer = -1; but don't think so
Only way is to make black window (part of panel) with overlay, then you'll be able to see the intity.
Other way it's just replace model of this cofee to bmap and if clicked (holding) then change to model by ent_morph.

Last edited by tompo; 06/29/07 15:05.

Never say never.
Re: entity doesn't react to mousepointer [Re: tompo] #138619
06/29/07 15:21
06/29/07 15:21
Joined: Jul 2004
Posts: 52
Vienna
H
Hawk Offline OP
Junior Member
Hawk  Offline OP
Junior Member
H

Joined: Jul 2004
Posts: 52
Vienna
if i replace the model to bmap it can't rotate while beeing touched :/
if I use the method i had used in the beginning the entity is in front of the panel.
you know, with
entity INV_kaffeebecher
{
...
}

with this method i also don't have to convert the coordinates, but unfortunately i can't touch and click it.

using your script my cup also keeps its position although the view turns. I want it to look always at the player in the same appearance. Like a 2d image.
Maybe there is a way to get the entity touchable in the other method?

or don't use vec_for_screen, but vec_to_screen to get a "2d entity", maybe then it won't be hidden by the panel. I tried to use vec_to_screen allready, but using that, the cup never appears. *shrug*


Commcercial A6.60
Re: entity doesn't react to mousepointer [Re: Hawk] #138620
06/29/07 15:32
06/29/07 15:32
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
to always look at you in the same appearance add in cup's loop:
vec_set(temp,camera.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);

vec_to_screen is oposite to vec_for_screen and for you is useless in this case
this is using to chenckig if entity is visible

Last edited by tompo; 06/29/07 15:34.

Never say never.
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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