Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-02-2010, 07:26 PM   #1
cmt9000
Registered User
 
Join Date: Sep 2007
Posts: 44
Default get all x & y coordinate values

I have created a triangle-shaped moving target graphic in Photoshop and added it as a movieClip.

Is there a way to get all x & y values that make up the movieClip?

thanks!
cmt9000 is offline   Reply With Quote
Old 11-03-2010, 01:01 PM   #2
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

You know, there are two types of images, one is vector graphics and involves co-ordinates and some simple math formulas to define a shape, and the second is pixel graphics which are made with tiny colored boxes and don't involve co-ordinates or math. The graphics you made in photoshop, belong to this second category, hence you can't access it's coordinates .Well, technically, you can get all of the co-ordinates for each pixel, but I don't think you want that.

If you can be a bit clear about your actual purpose, then I might be able to provide some actual help....as there is always multiple logical solutions for the same problem.
__________________
My Site :- http://blog.bluemagica.com

I need a spriter, and a story writer for arcade fighter and a side-view RPG. If you can help, please pm me!
bluemagica is offline   Reply With Quote
Old 11-03-2010, 01:24 PM   #3
cmt9000
Registered User
 
Join Date: Sep 2007
Posts: 44
Default

Hi bluemagica, thanks for the reply.

My game has a gun that shoots a laser(using lineTo/moveTo). I created targets in Photoshop and imported as movieClips, that I move across the screen.

When I fire the laser gun, I need to see if the line "hits" the target.

But as you said, since my targets are movieClips, they don't have x & y coordinates.

Do you know of a way to see if my line hits the target without using coordinates?

Thanks!
cmt9000 is offline   Reply With Quote
Old 11-03-2010, 01:47 PM   #4
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

1) When shooting, make a new Sprite() and push it in an array.
2) Add this sprite to the screen, and draw your laser inside it.
3) Go through your enemy-array, and simply hitTest the enemy and the bullet/laser sprite.
__________________
My Site :- http://blog.bluemagica.com

I need a spriter, and a story writer for arcade fighter and a side-view RPG. If you can help, please pm me!
bluemagica is offline   Reply With Quote
Old 11-03-2010, 02:20 PM   #5
cmt9000
Registered User
 
Join Date: Sep 2007
Posts: 44
Default

Quote:
Originally Posted by bluemagica View Post
1) When shooting, make a new Sprite() and push it in an array.
2) Add this sprite to the screen, and draw your laser inside it.
3) Go through your enemy-array, and simply hitTest the enemy and the bullet/laser sprite.
Hi bluemagica,

I'm having some trouble understanding when you say "push it in an array" and "draw your laser inside it".

Do you mean add each x&y location of the Sprite to an array?

And when you say draw, do you mean using moveTo/lineTo like I did previously?

I'm not sure how I would draw inside the sprite...

Thanks!
cmt9000 is offline   Reply With Quote
Old 11-03-2010, 02:35 PM   #6
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

-_-

Code:
function shootLaser(e:WhateverEvent):void
{
   var temp:Sprite = new Sprite();
   bulletArray.push(temp);
   addChild(temp);

   temp.graphics.lineStyle(4,0xFF87DF);
   temp.graphics.moveTo(myShip.x,myShip.y);
   temp.graphics.lineTo(endPointX,endPointY);
}

..
....
..........

function checkCollisions(e:Event):void
{
   for each(var spr:Sprite in bulletArray)
   {
        for each(var ene:* in enemyArray)
        {
             if(spr.hitTest(ene))
             {
                  trace("yay, finally managed to hit something useful");
             }
        }
   }
}
__________________
My Site :- http://blog.bluemagica.com

I need a spriter, and a story writer for arcade fighter and a side-view RPG. If you can help, please pm me!
bluemagica is offline   Reply With Quote
Old 11-03-2010, 03:11 PM   #7
cmt9000
Registered User
 
Join Date: Sep 2007
Posts: 44
Default

Wow, thanks!

I understand the concept of the code, and I think I can work with it except I'm not sure what to do with "enemyArray". My moving target is actually a movieClip. Would I do the same with this, create a Sprite, then put the movieClip inside that Sprite?

Thanks again for you help
cmt9000 is offline   Reply With Quote
Old 11-03-2010, 03:38 PM   #8
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

well normally we have multiple enemies just as we have multiple bullet's instances (by the way, you do know the difference between base-object and instances, right?), so assuming that, we normally store enemy instances in an array similar to how I stored the bullet instances in an array.....

If you have a single instance, you have no need for a nested loop, you just have to hitTest straight away against that particular instance.

PS: Movieclip and Sprite is basically the same thing except a "sprite" has only one frame, unlike movieclip which has it's own timeline.
__________________
My Site :- http://blog.bluemagica.com

I need a spriter, and a story writer for arcade fighter and a side-view RPG. If you can help, please pm me!
bluemagica is offline   Reply With Quote
Old 11-03-2010, 04:13 PM   #9
cmt9000
Registered User
 
Join Date: Sep 2007
Posts: 44
Default

An instance is like a clone of the base-object right? For example, I created a target graphic and put it on the stage. I'm assuming that's the base object. I then created a named instance of it. Am I on the right track here?
cmt9000 is offline   Reply With Quote
Old 11-03-2010, 04:18 PM   #10
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

Yep, you are right, except one thing, whatever you are putting on the stage is an instance, a temporary copy of the original object.......the original resides in the library.
__________________
My Site :- http://blog.bluemagica.com

I need a spriter, and a story writer for arcade fighter and a side-view RPG. If you can help, please pm me!
bluemagica is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:25 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.