11-02-2010, 07:26 PM
|
#1
|
|
Registered User
Join Date: Sep 2007
Posts: 44
|
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!
|
|
|
11-03-2010, 01:01 PM
|
#2
|
|
Senior Member
Join Date: Feb 2008
Posts: 387
|
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!
|
|
|
11-03-2010, 01:24 PM
|
#3
|
|
Registered User
Join Date: Sep 2007
Posts: 44
|
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!
|
|
|
11-03-2010, 01:47 PM
|
#4
|
|
Senior Member
Join Date: Feb 2008
Posts: 387
|
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!
|
|
|
11-03-2010, 02:20 PM
|
#5
|
|
Registered User
Join Date: Sep 2007
Posts: 44
|
Quote:
Originally Posted by bluemagica
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!
|
|
|
11-03-2010, 02:35 PM
|
#6
|
|
Senior Member
Join Date: Feb 2008
Posts: 387
|
-_-
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!
|
|
|
11-03-2010, 03:11 PM
|
#7
|
|
Registered User
Join Date: Sep 2007
Posts: 44
|
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
|
|
|
11-03-2010, 03:38 PM
|
#8
|
|
Senior Member
Join Date: Feb 2008
Posts: 387
|
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!
|
|
|
11-03-2010, 04:13 PM
|
#9
|
|
Registered User
Join Date: Sep 2007
Posts: 44
|
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?
|
|
|
11-03-2010, 04:18 PM
|
#10
|
|
Senior Member
Join Date: Feb 2008
Posts: 387
|
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!
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 02:31 PM.
///
|
|