Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't attach image to mouse cursor

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am trying to set an image's loc based on the mouseLoc. If I put the code for this in a mouseWithin handler, I experience a lag between the time the mouse moves and the time the image moves. How can I "attach" the image to the mouse so the image moves in synch with the mouse? I know it's possible because I've seen it in games like this one:
this is what I have been trying:

on mouseWithin me

courtSprite = sprite(1)
courtMember = courtSprite.member

posX = mouseH() - courtSprite.width/2
posY = (mouseV() - courtSprite.height/2) * -1

courtMember.model("du").transform.position = vector(posX, posY, -300)

end
 
I dont understand exactly what you want, but to make something move right with the mouse you can just put this script on a sprite:

on prepareframe me
sprite(me.spritenum).loc = the mouseloc
end

And if you dont want the cursor to show put:

on prepareframe me
sprite(me.spritenum).loc = the mouseloc
cursor 200
end

Not sure that's what you want, but this will make the sprite follow the mouse really closely, as long as your movie's framerate isn't really low.
 
Yeah sorry, I was half asleep when I wrote that last night. Let me explain this a little better. Basically, I'm just trying to build a 3D pong game. I have a 3D world with 3 objects in it... two paddles and a ball. I don't think the script you suggested will work because the paddle that I want attached to the cursor isn't a seperate sprite, it's just a model in the sprite. I used to write shockwave apps a few years back, but that was back around version 4... 8.5 might as well be a brand new environment for me. So, I'm not even very sure if this is the best way to do what I'm trying to do. Any help(maybe some useful tutorial links) pointing me in the right direction would be greatly appreciated. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top