ActionScript 2.0 :: HitTest Of Moving Object With Mouse?
Dec 17, 2009
My first post in Actionscript.org. but I'm a long time visitor / fan. I'm moving a object with mouse but using some easing values. means it will follow the mouse slower.
Here is the file.[URL].. How can i check hitTest in this situation. even if i do it normally...the object is passing the collision object simply before stopping..because its being moved with mouse..
[Code]...
View 0 Replies
Similar Posts:
Oct 25, 2011
I have a MovieClip. It represents animation of jumping monster. For clearness, let's pretend there are only 2 frames: the first one occupies top left rectangle (x = 0, y = 0, w = 70, h = 70) and the second one occupies (x = 100, y = 0, w = 70, h = 70). So monster jumps from left to the right. And position of MovieClip itself is constantly = (0, 0).
I'd like to fire some event when monster is clicked by mouse.
For some reason, I have stage mouse listener, not monster mouse listener. I wrote this code:
stage.addEventListener(MouseEvent.CLICK, onClick);
private final function onClick(e:MouseEvent):void {
const clickPos:Point = new Point(e.stageX, e.stageY);
// having monster:MovieClip, how do I check hitting it?
[Code] .....
View 1 Replies
Feb 9, 2011
Here is the code that I have, I know that these are the basic elements wihc I need to use, individually they work but together they don't
on (press) { this.startDrag(); } on (release) { stopDrag(); } }
this._y+= this._ymouse/4; this._x+= this._xmouse/4;
So what I am trying to do is to get the object to move slower than the mouse but finish moving wherever I let go of the click. So far I can get the object to move with the mouse without clicking and dragging at a slow speed but I cant get the drag to work at a slower speed, it will move as fast as the mouse moves.
View 1 Replies
Jul 14, 2011
It involves the player clicking on a moving movieclip which is boucing up and down on the screen. I started off using a 'mouse down' (not click, because the player must move the mouse before releasing it) event listener attached to the actual mc itself but this seemed to be horrendously innacurate. It LOOKED like I was clicking on the mc but was reacting as though I had missed completely. On the rare occasion that it actually detected a mouse down I thought I was some distance away.It seems that the object itself may be updating its position in memory before updating its position on screen if that makes sense? Has anyone had this issue before? Is there an easy way around it?
As a little test I used trace to output the calculated distance (using Point.distance(..)) between the mouse and the movieclip, most of the time it was returning values of between 70 and 90 pixles when I was definitely not that far away.
View 6 Replies
Mar 17, 2010
My problem is with moving object on the scene with mouse. I use addEventListener(MouseEvent.MOUSE_MOVE, ..) and everything works fine, until I start moving my mouse fast. Object is small (circle, radius 5) so my guess is that It don't update circle position fast enough to prevent mouse from leaving it.
View 7 Replies
Dec 13, 2006
I am trying to achieve a rollover effect like this menu.
[URL]
The menu is working and sliding perfectly, however it's still a little squirmish, and if I can't figure this out I'll deal with it and let it slide. However it's bugging me and want to correct the "sluggishness" of this issue. I want the menu to pause, or rest when you open it, so that there isn't a chance the it can slide off of the users mouse pointer.
Here is the code
Code:
onClipEvent (load) {
_y = 0;
speed = 5;
[Code]....
I thought a simple on (rollOver) speed = 0 would do the trick, however it just sends the menu in a frenzy.
View 3 Replies
Jan 22, 2009
I'm making a game where a character moves around a level and stays in the centre of the screen as the background scrolls past. I have created a movie clip of an enemy that moves up and down, and used hitTest to stop my character flying through the enemy and also to deduct a point from the score. However, if my character hits the enemy and stays underneath him, the enemy's movement pushes my character out of the screen, and you can no longer see him.
View 3 Replies
Jun 13, 2010
ok here is the scene
_root.playa
_root.playa.feetMC
_root.corneria
_root.corneria.limitsMC
[Code]...
View 3 Replies
Aug 26, 2009
I'm just curious how you'd hitTestObject a fast moving object? The problem I'm having is that my bullet seems to skip over large areas depending on the speed. Since the speed of my bullet is 40 pixels per millisecond (I think), it seems to only appear on the stage in instances that are 40 pixels apart, so I cannot hitTest in between those instances.
Here's an image of the bullet patturn as I hold down the shoot button. It just looks like this, unchanging. I won't be able to hit the yellow object ever.
View 2 Replies
Apr 22, 2007
I want to know how i can moving my scene by moving a mouse over them.
to understand what i want exactly ckeck this link :- [URL]
View 1 Replies
Jan 7, 2009
ok so if i have an obect called square1 and an object called square2 and inside square2 i have hitArea... i want to use shapeflag to detect an absolute true hitTest on just the area of square1 not the bounding box.... i tried this code and it didnt work...
actionscript 2.0
ActionScript Code:
if (_root.square1.hitTest(square2.hitArea._x, square2.hitArea._y, true)) {
View 2 Replies
Aug 24, 2009
[URL] when you have not clicked on all five dots, and you take the mouse of the stage, the interactive line should be deleted(graphics.clear(); ), and the little animation from the start should come back. my idea is to have a counter that ++ every frame, but when the mouse is moving on the stage the counter is constantly sett to 0. when the counter is, for example, 50 the animation i visible. do anyone have any methods that don't give the 50(for example) frame wait? and i would also like criticism and ideas on the rest.
View 7 Replies
Dec 4, 2008
why i am getting spurious mouse_out events when moving the mouse down or right but not up or left over a Sprite?
View 3 Replies
Mar 15, 2011
I have a function that checks if 2 objects are touching OB1 and OB2, if they do touch it runs the rest of the collision code where OB1 is the character and OB2 is a tile that the player cannot pass through.
I came across an issue where i wanted sprites to be separate from the hitboxes but my collision code works by checking the height and width of an object (you guys know the drill).
So i have a Tile class with 2 parts to it, a bitmap and a movieClip.
So i have this setup(pseudocode):
Code:
loop
{
function collision (ob1 , ob2[loop].movieclip)
}
This should work right? But it ONLY works for the first object in the loop!
View 4 Replies
Nov 24, 2003
I am creating a menu with nested MCs, of course, and the parent MC is using a RollOver action. The problem with that is: all other nested MC's RollOver action are not detected. I know you can use a mouse hitTest as a work-around i.e.:
Code:
onEnterFrame = function(){
if(this.hitTest(_xmouse,_ymouse,true)){
//do whatever
}}
But I'd like to avoid using that if possible.
View 7 Replies
Nov 24, 2003
im creating a menu with nested MCs, of course, and the parent MC is using a RollOver action. The problem with that is: all other nested MC's RollOver action are not detected. I know you can use a mouse hitTest as a work-around ie:
Code:
onEnterFrame = function(){
if(this.hitTest(_xmouse,_ymouse,true)){
//do whatever
}
}
but i'd like to avoid using that if possible.
View 7 Replies
Mar 27, 2011
I've googled for hours and found nothing. I did find a lot but none involved hittesting with a mouse cursor. I'm trying to make a simple maze game, so far it works, I die when I hit squares and rectangles, but I die incorrectly when hitting a rotating rectangle.Because it rotates, the bounding box is larger and a normal hittest sees bounding boxes, meaning it won't work.Make it so that my mouse can go near the rotating rectangle without dying until I actually touch the actual rectangle instead of the bounding box.
View 2 Replies
Jul 31, 2011
Having used copyPixels to display an image, I'm trying to copy another in it's place when the mouse is hovering.The only way I can copy the new image over the old is by setting the If statement to == false. I know there's something wrong with testing the bitmapData of the loaded .png because the hitTest would apply to anything copied from that tile sheet... but how to designate just the copied area?
ActionScript Code:
package
{
[code]......
View 4 Replies
Jul 16, 2007
I am attempting to build a xml driven drop down menu where everything is taken from xml. now the problem arises with submenues. I have them being created fine, but it's the mouse out that won't work. I want to use a hittest to check if my mouse is over any of the submenues and if not just to trace something so I know it's working.
The problem is when i mouse of one clip onto the next it fails the hittest and traces. There isn't a space between the two MC's so I dunno what would be causing this. I have read sen's guide but I'm not pulling things from the library. Everything is being created at run time so I can't use the attach movie, so I am just positioning them below each other.
[code]...
View 2 Replies
Oct 20, 2010
i have a hit test point on display object, and if i exit stage over that display object, and then run hit test point it will return true, although my mouse is not over stage area any more, like it remembers the last mousex, mousey coordinates where mouse was and reports that.how do i deal with it?i know i can detect mouse_leave on stage and mouse_out on displayobject.
View 3 Replies
Jan 21, 2004
Ive got a code to move a MC on the main stage together with the mouse, in the the X axis,. difficult to explain. But now the client wants that this MC movement works only when the Y position of the mouse is over the 300 px. I thought I need a hit test or something elese. Please help. Here is the whole code.
[Code]....
View 1 Replies
Feb 7, 2009
I am trying to write a class that will hittest for my mouse touching a menu. The class is attached to the linkage of the actual menu MC. I can't seem to get a hit, I think, what am I doing wrong?
Code:
import mx.events.EventDispatcher;
import mx.utils.Delegate;
[code]......
View 2 Replies
Dec 1, 2009
This seems like it should be simple, but... I've been trying to figure out how to do the following, and I can't seem to make it work. It all works except for the hit test part. I have a working drag and drop application. I need something different to happen when the user drops an object while the mouse x,y is, or is not over a certain (very irregularly shaped) bitmap inside a movieClip. how to do this? I have found some complicated ways to hit test between 2 bitmaps, but not 1 bitmap and mouse x,y.
View 3 Replies
Apr 6, 2011
I am working on an application where an image serves as cursor. Now i would like to know at any time over which object the cursor is hovering. Sort of like a HitTestObject(*) where i can then see what object the * represents. how i could accomplish this? (and using the mouse is not an option)
View 2 Replies
Feb 23, 2012
I am trying to do a apply a tween for the width property on a MovieClip Object but every time it changes the width and the position too, and I don't want that. I want to change the width going to one side without changing the x and y of the object.
I tried both of thes and they gave the same result.
var c:Tween = new Tween(left, "scaleX", Strong.easeOut, 1, 1.5,20,true);
var c:Tween = new Tween(left, "width", Strong.easeOut, 20, 200,20,true);
I think it is applying the transformation according to a center of the movie clip. but I don't know how it can be changed.
View 2 Replies
Apr 13, 2011
Im working on a small project and it involves a guy which you move with the arrow keys. The arrow keys add to his x, y velocities and his position is updated accordingly. How can i get this man to grab onto an object and spin around it (like when you grab pole and letting your momentum swing you around) . I can make him grab the object but I dont know how to modify his x,y speeds to simulate the arc.
View 4 Replies
Oct 13, 2010
my title explains what im need but im using flash cs4 and heres what i have so far:
var centerX:Number;
var centerY:Number;
var centerZ:Number;
[Code].....
ok so RBall is my first moving object and my orbiting object will be called orbit
View 9 Replies
Feb 27, 2012
I would like to know if there's the way to do collision check on every object on the stage,
[Code]...
I want to make the object such that it falls on a rotated platform and land according to it's angle. I've success fully make it landed according to it's angle before it lands. but the problem here is that, after the landing when I trigger the rotating platform, the object falls when the platform is out of it's hit area. Is there a way such that it will work like a car wiper and wipe the object towards it's direction?
View 3 Replies
Jul 10, 2010
I'm coding a really simple 2D platforming game in Flash using AS3. I'd like to define two different types of terrain surfaces that the player can walk on based on classic platforming elements. Type1: the player can walk on, and if the player jumps, they will hit their head on it and bounce back to the ground. Type2: the player can also walk on, but if the player jumps and hits their head, they will simply pass through the surface and not bounce back to the ground.
I am using hitTestPoint to resolve collisions for this. My question is: What would be the best method to test for what TYPE of ground I am colliding with? Each ground type has it's own Class associated with it in my Flash IDE and all the different terrain surface types are in the same movie clip on the stage.
Currently I'm testing to see if it hit one type of ground surface, then i'm testing if it hit the other, and then based on those results, I process what I want to happen. This seems to work okay right now, but I'm imagining that I may want to create more than 2 types of ground to collide with. For example, moving platforms. It seems like the code will start to get complex
Eg.
if(_groundType1.hitTestPoint(_player.x, _player.y, true))
{
if(_groundType2.hitTestPoint(_player.x, _player.y, true))
[Code].....
View 1 Replies
Aug 23, 2011
I have converted a PNG into a bitmap, then converted that into bitmapData.
I have a object called _player, and I wish to add collision detection, however I can seem to get it to work.
my code is:
if(bmd1.hitTest(new Point(_player.x, _player.y))){
trace("hit");
}
bmd1 is my bitmapData,_player is the object is wish to test against.
I am getting the following error:
1136: Incorrect number of arguments, Expected 3
I have looked around but cannott find what argument I am missing
I have tried
if(bmd1.hitTest(new Point(_player.x, _player.y), 50, _player)){
trace("hit");
}
I should mention that the reason for me taking this approach is that I have a PNG, with transparent areas, I need to test for collisions in the non-transparent areas, which is why I was using this approach
I have a PNG, i import that and convert to bitmap, then convert to bitmapData
View 3 Replies