Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

DIR MX 2004

4 réponses
Avatar
Mas Fabien
Bonjour , je voudrais intercepter n'importe quel click souris pendnat mon
animation, que ce soit sur une image objet avec un script ou sur ma scene
pour cela je cree un script d'animation avec un evenement on mouseDown mais
cela omet des evenements ...

4 réponses

Avatar
Bubar
Mas Fabien wrote:
Bonjour , je voudrais intercepter n'importe quel click souris pendnat
mon animation, que ce soit sur une image objet avec un script ou sur
ma scene pour cela je cree un script d'animation avec un evenement on
mouseDown mais cela omet des evenements ...


Les évènements sont interceptés dans cet ordre :
comportements de sprites sur lesquels l'évènement s'et produit
script de frame
scripts d'animation

Si le mousedown se fait sur un sprite qui a un comportement avec un
mousedown, celui-ci réagit et bloque le mousedown.
Tu as plusieurs solutions pour faire suivre le mousedown.
- La fonction pass
- tu crèes une fonction dans un script d'animation (ex on
reagitmousedown) qui va contenir ton code du mousedown
dans ton script d'animation qui contient le mousedown, tu ne fais
qu'appeler reagitmousedown()
dans tous les comportements qui ont un mousedown, tu fais aussi appel à
reagitmousedown()

--
Bubar
Avatar
Sébastien Portebois
Le Fri, 16 Apr 2004 11:14:03 +0200, Mas Fabien a écrit:

Bonjour , je voudrais intercepter n'importe quel click souris pendnat mon
animation, que ce soit sur une image objet avec un script ou sur ma scene
pour cela je cree un script d'animation avec un evenement on mouseDown
mais cela omet des evenements ...



salut Fabien.

Une autre approche, un peu plus lourde, mais qu ia l'avantage de ne pas
nécessiter la moindre modif dans les scripts existants, et l'utilisation
d'un objet qui va 'écouter' les clics de souris.

Voici un script parent, rapidement adapté d'un autre que j'utilise
intensément, et qui doit faire (avec peut-être quelques corrections) cette
écoute. Les deux dernières méthodes sont appellées lorsqu'un mouseUp ou un
mouseDown survient.

bonne journée
séb

-- script parent "PS_mouseDown trapping"

--================================================= -- DEPENDENCIES
--================================================= -- none ;¬)

-- API
-- * new(
-- * mKill()

-- sample :
-- oMouseWatcher = script("PS_mouseDown trapping").new()

--================================================= -- GLOBALS
--================================================= global g, gSp, gL


--================================================= -- PROPERTIES
--================================================= property ancestor

property pnChannel
property pbWasClicked, pbClickDone

property ptoStopMovieCatcher


----------------------------------------------------------------------
---- CONSTRUCTOR ---- CONSTRUCTOR *
on _____________________CONSTRUCTOR_________________________________()

on new (me, params)
if me.miInit(params) then return me
end

on stopMovie me
--> send by the timeout
me.mKill()
end

on mKill (me)
me.miKill()
end


on stepFrame me
if the mouseDown then
-- mouseDown?
if NOT pbWasClicked then me.miStartClick()

else
-- mouseUp?
if pbWasClicked then me.miStopClick()
end if
end



----------------------------------------------------------------------
---- PRIVATE METHODS ---- PRIVATE *
on _____________________PRIVATE_METHODS___________________________()


on miInit (me, nSpriteChannel) ---------------------------------------
-- PRIVATE
-- > new
--
-- INPUTS:
-- nSpriteChannel <#integer> : the sprite channel to trap mouse
-- events for.
-------

if not integerP(nSpriteChannel) then return FALSE
pnChannel = nSpriteChannel
(the actorList).add(me)

ptoStopMovieCatcher = timeout("stopMovie"&me.string).new(the maxInteger,
#dummy, me)

return TRUE
end -- miInit handler


on miKill (me) -------------------------------------------------------
-- PRIVATE
-- > mKill
-------

if not voidP(ptoStopMovieCatcher) then
ptoStopMovieCatcher.target = VOID
ptoStopMovieCatcher.forget()
ptoStopMovieCatcher = VOID
end if

(the actorList).deleteOne(me)
end -- miKill handler




on miStartClick (me) -------------------------------------------------
-- PRIVATE
--> stepFrame
-------


pbWasClicked = TRUE

lInfos = propList()
lInfos[#frame] = the frame
lInfos[#spriteNum] = the clickOn
lInfos[#loc] = the clickLoc
lInfos[#timeStamp] = the milliseconds

-- toutes les infos sur le mouseDown sont contenues dans la liste lInfos

pbClickDone = TRUE
end -- miStartClick handler


on miStopClick (me) --------------------------------------------------
-- PRIVATE
--> stepFrame
-------

if pbWasClicked then

lInfos = propList()
lInfos[#frame] = the frame
lInfos[#spriteNum] = the clickOn
lInfos[#loc] = the mouseLoc
lInfos[#timeStamp] = the milliseconds

-- toutes les infos sur le mouseUp sont contenues dans la liste lInfos

pbWasClicked = FALSE
end if
pbClickDone = FALSE
end -- miStopClick handler


on _____________________END_OF_OBJECT_____________________ ()
on _______________________________________________________________()
end
Avatar
Mas Fabien
Merci :)
"Sébastien Portebois" a écrit dans
le message de news:
Le Fri, 16 Apr 2004 11:14:03 +0200, Mas Fabien a écrit:

> Bonjour , je voudrais intercepter n'importe quel click souris pendnat


mon
> animation, que ce soit sur une image objet avec un script ou sur ma


scene
> pour cela je cree un script d'animation avec un evenement on mouseDown
> mais cela omet des evenements ...

salut Fabien.

Une autre approche, un peu plus lourde, mais qu ia l'avantage de ne pas
nécessiter la moindre modif dans les scripts existants, et l'utilisation
d'un objet qui va 'écouter' les clics de souris.

Voici un script parent, rapidement adapté d'un autre que j'utilise
intensément, et qui doit faire (avec peut-être quelques corrections) cette
écoute. Les deux dernières méthodes sont appellées lorsqu'un mouseUp ou un
mouseDown survient.

bonne journée
séb

-- script parent "PS_mouseDown trapping"

--================================================= > -- DEPENDENCIES
--================================================= > -- none ;¬)

-- API
-- * new(
-- * mKill()

-- sample :
-- oMouseWatcher = script("PS_mouseDown trapping").new()

--================================================= > -- GLOBALS
--================================================= > global g, gSp, gL


--================================================= > -- PROPERTIES
--================================================= > property ancestor

property pnChannel
property pbWasClicked, pbClickDone

property ptoStopMovieCatcher


----------------------------------------------------------------------
---- CONSTRUCTOR ---- CONSTRUCTOR *
on _____________________CONSTRUCTOR_________________________________()

on new (me, params)
if me.miInit(params) then return me
end

on stopMovie me
--> send by the timeout
me.mKill()
end

on mKill (me)
me.miKill()
end


on stepFrame me
if the mouseDown then
-- mouseDown?
if NOT pbWasClicked then me.miStartClick()

else
-- mouseUp?
if pbWasClicked then me.miStopClick()
end if
end



----------------------------------------------------------------------
---- PRIVATE METHODS ---- PRIVATE *
on _____________________PRIVATE_METHODS___________________________()


on miInit (me, nSpriteChannel) ---------------------------------------
-- PRIVATE
-- > new
--
-- INPUTS:
-- nSpriteChannel <#integer> : the sprite channel to trap mouse
-- events for.
-------

if not integerP(nSpriteChannel) then return FALSE
pnChannel = nSpriteChannel
(the actorList).add(me)

ptoStopMovieCatcher = timeout("stopMovie"&me.string).new(the


maxInteger,
#dummy, me)

return TRUE
end -- miInit handler


on miKill (me) -------------------------------------------------------
-- PRIVATE
-- > mKill
-------

if not voidP(ptoStopMovieCatcher) then
ptoStopMovieCatcher.target = VOID
ptoStopMovieCatcher.forget()
ptoStopMovieCatcher = VOID
end if

(the actorList).deleteOne(me)
end -- miKill handler




on miStartClick (me) -------------------------------------------------
-- PRIVATE
--> stepFrame
-------


pbWasClicked = TRUE

lInfos = propList()
lInfos[#frame] = the frame
lInfos[#spriteNum] = the clickOn
lInfos[#loc] = the clickLoc
lInfos[#timeStamp] = the milliseconds

-- toutes les infos sur le mouseDown sont contenues dans la liste


lInfos

pbClickDone = TRUE
end -- miStartClick handler


on miStopClick (me) --------------------------------------------------
-- PRIVATE
--> stepFrame
-------

if pbWasClicked then

lInfos = propList()
lInfos[#frame] = the frame
lInfos[#spriteNum] = the clickOn
lInfos[#loc] = the mouseLoc
lInfos[#timeStamp] = the milliseconds

-- toutes les infos sur le mouseUp sont contenues dans la liste


lInfos

pbWasClicked = FALSE
end if
pbClickDone = FALSE
end -- miStopClick handler


on _____________________END_OF_OBJECT_____________________ ()
on _______________________________________________________________()
end


Avatar
Sébastien Portebois
Salut

Envoyé trop vite... pour que ca fonctionne, il fallait épurere la méthode
mInit, ou recopier celle ci dessous:

on miInit (me) -------------------------------------------------------
-- PRIVATE
-- > new
--
-------

(the actorList).add(me)

ptoStopMovieCatcher = timeout("stopMovie"&me.string).new(the maxInteger,
#dummy, me)
return TRUE
end -- miInit handler

bye
séb


Voici un script parent, rapidement adapté d'un autre que j'utilise
intensément, et qui doit faire (avec peut-être quelques corrections)
cette écoute. Les deux dernières méthodes sont appellées lorsqu'un
mouseUp ou un mouseDown survient.

bonne journée
séb

-- script parent "PS_mouseDown trapping"

--================================================= > -- DEPENDENCIES
--================================================= > -- none ;¬)

-- API
-- * new(
-- * mKill()

-- sample :
-- oMouseWatcher = script("PS_mouseDown trapping").new()

--================================================= > -- GLOBALS
--================================================= > global g, gSp, gL


--================================================= > -- PROPERTIES
--================================================= > property ancestor

property pnChannel
property pbWasClicked, pbClickDone

property ptoStopMovieCatcher


----------------------------------------------------------------------
---- CONSTRUCTOR ---- CONSTRUCTOR *
on _____________________CONSTRUCTOR_________________________________()

on new (me, params)
if me.miInit(params) then return me
end

on stopMovie me
--> send by the timeout
me.mKill()
end

on mKill (me)
me.miKill()
end


on stepFrame me
if the mouseDown then
-- mouseDown?
if NOT pbWasClicked then me.miStartClick()

else
-- mouseUp?
if pbWasClicked then me.miStopClick()
end if
end



----------------------------------------------------------------------
---- PRIVATE METHODS ---- PRIVATE *
on _____________________PRIVATE_METHODS___________________________()


on miInit (me, nSpriteChannel) ---------------------------------------
-- PRIVATE
-- > new
--
-- INPUTS:
-- nSpriteChannel <#integer> : the sprite channel to trap mouse
-- events for.
-------

if not integerP(nSpriteChannel) then return FALSE
pnChannel = nSpriteChannel
(the actorList).add(me)

ptoStopMovieCatcher = timeout("stopMovie"&me.string).new(the
maxInteger, #dummy, me)

return TRUE
end -- miInit handler


on miKill (me) -------------------------------------------------------
-- PRIVATE
-- > mKill
-------

if not voidP(ptoStopMovieCatcher) then
ptoStopMovieCatcher.target = VOID
ptoStopMovieCatcher.forget()
ptoStopMovieCatcher = VOID
end if

(the actorList).deleteOne(me)
end -- miKill handler




on miStartClick (me) -------------------------------------------------
-- PRIVATE
--> stepFrame
-------


pbWasClicked = TRUE

lInfos = propList()
lInfos[#frame] = the frame
lInfos[#spriteNum] = the clickOn
lInfos[#loc] = the clickLoc
lInfos[#timeStamp] = the milliseconds

-- toutes les infos sur le mouseDown sont contenues dans la liste
lInfos

pbClickDone = TRUE
end -- miStartClick handler


on miStopClick (me) --------------------------------------------------
-- PRIVATE
--> stepFrame
-------

if pbWasClicked then

lInfos = propList()
lInfos[#frame] = the frame
lInfos[#spriteNum] = the clickOn
lInfos[#loc] = the mouseLoc
lInfos[#timeStamp] = the milliseconds

-- toutes les infos sur le mouseUp sont contenues dans la liste
lInfos

pbWasClicked = FALSE
end if
pbClickDone = FALSE
end -- miStopClick handler


on _____________________END_OF_OBJECT_____________________ ()
on _______________________________________________________________()
end