The mouse events are probably stopped somewhere else in your project, search through your scripts for other instances of mouse events and use the pass command. Another source could be if the sprite isn't editable, if so it will ignore mouse clicks. There is also other reasons that might cause this that I can't recall right now, but I usually have mouse catching code in one of my main scripts that checks which sprite was clicked (clickOn) and routs the event to the correct sprite, useful if you for example have several sprites with mouse events that can block each other.
Edit, in your code you have the end statement for the "on enterframe" last in your script instead of before the "on mouseDown", Director usually don't care about that, but it can't hurt to fix it.
Hi,thank u very much for your reply!
I don't know how to use the pass command.I have one sprite in the game.the sprite(1).
I can't give any explanation.In the test area the mouse click (active) only in the 2 sides of the stage(imagine the stage separated to 3 vertical pieces),in the middle nothing happens.
is there any example with code ?
If you don't have any other script in your project that uses the mousedown handler, you wont need to use the pass command.
Try adding sprite(1).editable = true to your on beginsprite handler and see if it works.
Edit: Btw It's better not to hard code sprite numbers in your scripts, if you move your sprite in the score, your movie will no longer work as it should. Try adding a property for the sprite number, for example:
on beginsprite me
pSpriteNum = me.spritenum
sprite(pSpriteNum).editable = true
or even better store a referens to the sprite
on beginsprite me
pSprite = sprite(me.spriteNum)
pSprite.editable = true
Thank u very much!
I solved the problem!I had created an avatar(sphere) and I was moving with this model with the camera as a child from behind.
The avatar was invisible,but it was in front of the view that's why I couldn't click on anynthing.
I put the avatar a little bit up(z axis) end now is working!
Ah, ok, so the sprite was reacting to clicks then.
For you, instead of using modelunderloc you could use the simillar command modelSunderLoc which returns all models under the mouse, and then loop through the returnd list of models and search for your models. This way it doesn't matter if any other models are in the way
replace your modelhit line with: (modefied from the example code in directors help section under modelsunderloc)
tModelList = [pBox, pBox2] -- only look for the box models
tOptionsList = [#levelOfDetail: #simple, #modelList: tModelList] -- #simple: we only need model references
modelhit = sprite(1).camera.modelsUnderLoc( ptklik, tOptionsList)
and change your "on hit whichmodel" with this one
on hit whichmodel
if not whichmodel then
repeat with i = 1 to whichmodel.count
case whichmodel[i] of
Note: Since I'm not at the time of writing this able to test this in director, the list returned from modelsunderloc might be structured differently than a simple list of model references, so you might need to modify the case statment a bit.