Mouse Click

Posted By: Sorrowful

Mouse Click - 07/08/12 17:39

Code:
if(mouse_left==1)
   {
   	ent_animate(me,"5atak",ates_per,ANM_CYCLE);
   	ates_per += 1*time_step;
   }



I want to be when I click the mouse once...
Posted By: rayp

Re: Mouse Click - 07/08/12 17:47

Do u call it from a while loop ?
Do u want to execute it only one time ?
Posted By: sivan

Re: Mouse Click - 07/08/12 17:52

it's okay, if placen in a while(1) loop having wait(1) in the end , but if(mouse_left) is enough.
Posted By: rayp

Re: Mouse Click - 07/08/12 18:03

If "5atak" means attack. Then this wont work in a simple while. Cause the attack animation only would be played when holding mouse_left. I think (without knowing it, cause of no informations) he want to have a kind of a oneshot-animation.
Posted By: Espér

Re: Mouse Click - 07/09/12 04:47

i think this could work:
Code:
var hitleft = 0;
...

if(mouse_left==1 && hitleft ==0)
{
	hitleft = 1;
	ates_per = 0;
   	while(ates_per<99)
	{
		ent_animate(me,"5atak",ates_per,ANM_CYCLE);
   			ates_per += 1*time_step;
		wait(1);
	}
	ates_per = 100;
	ent_animate(me,"5atak",ates_per,ANM_CYCLE);
	hitleft = 0;
}



bit i think you should use me.skillXX instead of ates_per.. cause a global variable as frame counter is not effective in greater scenes with more animations laugh
Posted By: rayp

Re: Mouse Click - 07/09/12 06:15

Yeah but when using this code, the main-while is paused until the animation is done. If he does further movement fex in the main while, this wont work. And why do u use ent_animate again after the while ?

whats about this one. Full animation played from main-while without pausing it.
Code:
#define Satack   skill100
#define ates_per skill99

function anm_me()
{
  while(my)
  {
    if(my.Satack == 1) { my.ates_per += time_step; ent_animate(me, "Satak", my.ates_per, ANM_CYCLE); }

    if(my.ates_per >= 100) { my.ates_per = 0; my.Satak = 0; }
    wait(1);
  }
}

action The_Player()
{
  anm_me();
  while(my)
  {
    if(mouse_left && my.Satack == 0) my.Satack = 1; 
    //further code in main while like movement whatever
    wait(1);
  }
}


Now if mouse_left is pressed the full animation will be displayed without pausing the main-while.

mfg
Posted By: Espér

Re: Mouse Click - 07/09/12 06:29

would be an idea..
but only if you got 1 or 2 animated models at a time.. if there will be more, with different pointer names.. the main loop won't work.. the animation needs ro be in the entities action

my code is not meant to be in the main loop. it's coded to be part of the entities action smirk
Posted By: rayp

Re: Mouse Click - 07/09/12 06:34

Quote:
but only if you got 1 or 2 animated models at a time.. if there will be more, with different pointer names.. the main loop won't work.. the animation needs ro be in the entities action
This is not true. With this code above u can have 1000 of entitys. Which pointers ? It only uses "my" called from each entity. So this script above works with ALL The_Player actions in game.
Posted By: Espér

Re: Mouse Click - 07/09/12 06:36

ah
i see
sry - misunderstood the script ^_^" - forget whatever i said
Posted By: rayp

Re: Mouse Click - 07/09/12 06:39

no problem thanks for thinking with me to solve the problem. But the threadstarter seems not really interested ^^
© 2024 lite-C Forums