PDA

View Full Version : V-Cam Cursor



AsSeenOnTV
03-01-2010, 05:05 PM
This is possible, isn't it?
http://www.truploader.com/uploads/411649vcamcursor.gif

I can get the V-Cam to follow the cursor, but I'd like to stop it's X movements when it collides with a vertical wall, and its Y movements when it collides with a horizontal wall.
I know it's possible, but I just don't know where to start.

If I get to know this, games like this (http://www.truploader.com/view/805183) will appear.
And they won't suck.

Ahtex!
03-01-2010, 05:14 PM
im interested in this also, maybe you could decompile that .swf?

AsSeenOnTV
03-01-2010, 06:02 PM
im interested in this also, maybe you could decompile that .swf?
Sure, it's what you should expect. I made it smaller so it was uploadable and uploaded it to this place. http://www.exoload.com/310/vcamaimer.fla

AsSeenOnTV
03-01-2010, 09:03 PM
Alright, hit tests.

I've learned about hit tests. It wasn't too bad.
All I need to know is if there is a way to say something like "y =/= ymouse" and be able to take mouse control, even negative and positive, away from the object while it hits a wall. That's what I need to know.

Bonk
03-02-2010, 02:44 AM
You need a condition:



if ((vcam._y > 0) && (vcam._x > 0) && (vcam._y < //stageheight) && (vcam._x < //stagewidth)) {
//whatever your vcam movement code is
}


I'm not too good with &&s ("and"s) so the actual technical aspect of my code may not work, but that sort of thing is what you need.

GreenSheen
03-02-2010, 01:29 PM
I had an idea for this that might work but I'm not to shure how to word into as2 but anyways it should be something along the lines of:

If the v-cam's x position is more than the end of the stage (right side coordinates) than stop following the cursors x axis. If the v-cam's x position is more than the end of the stage (left side coordinates) than stop following the cursors x axis. If the v-cam's y position is more than the end of the stage (top side coordinates) than stop following the cursors y axis. If the v-cam's y position is more than the end of the stage (bottom side coordinates) than stop following the cursors y axis.

As I said I think that might work but I don't really know how to code it. I'll mess around a little with it when I get back home but Its time to go job hunting :\

AsSeenOnTV
03-02-2010, 03:00 PM
Well, instead of the stage, I'd like to just use walls.

http://www.truploader.com/uploads/056385hitsystem.png
This is what I want it to look something like. I've typed the hit test action for the object following the cursor on the walls. I know + and - don't work.

I also remembered that Y is flipped in Flash.

GreenSheen
03-02-2010, 08:16 PM
This is gonna drive me insane. I've already made two failed tests.
Well here goes a third one but i got an idea for it (that'll prolly fail too, argh). Have an object follow the mouse, and a camera follow that object?

my head hurts :\

AsSeenOnTV
03-02-2010, 08:45 PM
Hasn't anyone seen something like this before? http://www.truploader.com/view/130958 (I seriously couldn't find anything so I made my own. It's just an animation, I didn't actually get it to work, if you're wondering)
It's been done, it can't be that complicated. Just a barrier that it doesn't go past

GreenSheen
03-02-2010, 08:50 PM
You'd be surprised how complicated the simplest things are. I'm just getting the hang of AS2 myself. Complicated only begins to describe it.

RawGreen
03-02-2010, 10:55 PM
Aw I only get 2 points for a groin shot.

Kitsune used the right scripts you want in the gray-scale collaboration(I think it's this one)

otherwise look through his works on newgrounds for the right scripts, you script kitty .

xD

Arch-Angel
03-03-2010, 12:27 AM
[QUOTE]var delay:Number = 0.2 /*Change depending on how much delay you want*/
onEnterFrame = function () {
cam._y += (_ymouse - cam._y) * delay;
cam._x += (_xmouse - cam._x) * delay;
};[/QUOTE

That's the code you're looking for, buddy.

Google helps, ya know.

Scorpioxxx
03-06-2010, 08:32 AM
I might have an idea of how to do it but it's kinda cheating.

If you're only using a simple box then you can use this type of script, adapted from bonk's one that he posted:


onClipEvent (enterFrame) {
if ((vcam._y > walltop._y) && (vcam._x > wallleft.x) && (vcam._y < wallbottom._y) && (vcam._x < wallright._x)) {
//whatever your vcam movement code is
}
}

Each 'wall' is a 1 pixel thick line that is set horizontaly or vertically where you want the max/min X or Y for the camera to be.

I may have ****ed up my axis' but you need 4 walls instanced walltop, wallbottom, wallleft and wallright and the code checks you are between the top, bottom left and right walls, (in the box) and if you are its letting the camera location = the mouse location. If you're not using a simple box, i'll have to go digging for scripts.

If it doesn't work, try revising which way round I have the axis or checking syntax since opening flash to check this properly is way to much work.

AsSeenOnTV
03-06-2010, 11:18 AM
Scorpio, I really don't see what you're going for with the script there.

Is there a way to take away control of NEGATIVE Y when the vcam touches the BOTTOM WALL? And POSITIVE X when it toughes the RIGHT WALL? It's so simple, I swear I've seen a vcam cursor somewhere.

Scorpioxxx
03-06-2010, 12:17 PM
Scorpio, I really don't see what you're going for with the script there.

Is there a way to take away control of NEGATIVE Y when the vcam touches the BOTTOM WALL? And POSITIVE X when it toughes the RIGHT WALL? It's so simple, I swear I've seen a vcam cursor somewhere.

I think I completly missunderstood what you're trying to do, I thought you were trying to make the camera follow the mouse unless is went outside a certain area, I assume this isn't the case and I'm trying to get my head around what you really mean since every cursor controlled camera I've used was with that setup or a similar one that used near identical code but dealt with the X and Y axis separately. I'll see if anything clicks in the next few hours while I'm supposed to be doing something else.