[flash]pb retournement vertical

rrrrrrrrrr -  
 rrrrrrrrrrr -
Bonjour,

J'esseye de retourner un clip verticalement, ça fonctionne mais pas à tous les coups. Et ca fini par s'inverser.
Le code :

onClipEvent(mouseDown) {
	// droite
	if(_root.tux._x < _root._xmouse )
	{
		_root.tux._xscale *= 1 ;
		if(_root.tux._x <= _root._xmouse)
		{
			_root.droite = 1 ;
			_root.gox = 	_root._xmouse ;
		}
	}
	//gauche
	if(_root.tux._x > _root._xmouse )
	{
		_root.tux._xscale *= -1 ;
		if(_root.tux._x >= _root._xmouse)
		{
			_root.gauche = 1 ;
			_root.gox = 	_root._xmouse ;
		}
	}
}


onClipEvent(enterFrame)
{
	if(_root.droite == 1)
	{
		_root.tux._x = _root.tux._x + 3;
		if(_root.tux._x >= _root.gox)
			_root.droite = 0 ;
	}
	if(_root.gauche == 1)
	{
		_root.tux._x = _root.tux._x - 3;
		if(_root.tux._x <= _root.gox)
			_root.gauche = 0 ;
	}
}


Pourquoi ca ne fonctionne pas à tous les coups pourtant la direction fonctionne bien elle.

Je sais le code n'est pas optimisé mais ça viendra peut etre :D
A voir également:

3 réponses

rrrrrrrrrr
 
Pardon, je repete un if, c'est mieux comme ca mais ca fait la meme chose .

onClipEvent(load)
{
	_root.gox = 0 ;
	_root.droite = 0 ;
	_root.gauche = 0 ;
}

onClipEvent(mouseDown) {
	
		if(_root.tux._x <= _root._xmouse)
		{_root.tux._xscale *= 1 ;
			_root.droite = 1 ;
			_root.gox = 	_root._xmouse ;
		}
		
		if(_root.tux._x >= _root._xmouse)
		{_root.tux._xscale *= -1 ;
			_root.gauche = 1 ;
			_root.gox = 	_root._xmouse ;
		}
}

onClipEvent(enterFrame)
{
	if(_root.droite == 1)
	{
		_root.tux._x = _root.tux._x + 3;
		if(_root.tux._x >= _root.gox)
			_root.droite = 0 ;
	}
	if(_root.gauche == 1)
	{
		_root.tux._x = _root.tux._x - 3;
		if(_root.tux._x <= _root.gox)
			_root.gauche = 0 ;
	}
}


:(
0
rrrrrrrrrrrr
 
C'est bon je viens de trouver :)

en fait le xscale *= -1 inverse dans un sens. Si je le refait ca remets a l'endroit.
Je croyais bettement que -1 etait dans un sens et +1 dans l'autre :D

C'est en le mettant dans enterframe que j'ai apercu qu'il avait un peu le parkinson mon tux :D
0
rrrrrrrrrrr
 
Voici donc le code modifié qui fonctionne :

onClipEvent(load)
{
	_root.gox = 0 ;
	_root.droite = 0 ;
	_root.gauche = 0 ;
	_root.dirdroite = 0 ;
	_root.dirgauche = 0 ;
}

onClipEvent(mouseDown) {
	
		if(_root.tux._x < _root._xmouse)
		{
			if(_root.dirgauche == 1)
				_root.tux._xscale *= -1 ;
			_root.droite = 1 ;
			_root.gox = 	_root._xmouse ;
			_root.dirdroite = 1 ; 
			_root.dirgauche = 0 ;
		}
		
		if(_root.tux._x > _root._xmouse)
		{
			if(_root.dirdroite == 1)
				_root.tux._xscale *= -1 ;
			_root.gauche = 1 ;
			_root.gox = 	_root._xmouse ;
			_root.dirgauche = 1 ; 
			_root.dirdroite = 0 ; 
		}
}

onClipEvent(enterFrame)
{
	if(_root.droite == 1)
	{
		_root.tux._x = _root.tux._x + 3;
		if(_root.tux._x >= _root.gox)
			_root.droite = 0 ;
	}
	if(_root.gauche == 1)
	{
		_root.tux._x = _root.tux._x - 3;
		if(_root.tux._x <= _root.gox)
			_root.gauche = 0 ;
	}
}

0