Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: sit on top of an mc?

(226 views • 15 replies)

This topic is 1 page long.

<< < > >>
Sleeping

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 02:30 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

:just when i thought i had done it......

ok i'm making a p "n" c game and i know how to change frames, find the items, drag then into the inventory and then they go into the inventory. i'v got EVERYTHING but it's just this one part that i need, then that'ss me done (well i can do it).
whats wrong: i have the dragable mc, that drags into another mc, and changes the second mc into the inventory with the first mc on it. so i should be able to drag it out. i can't. so i was thinking is there away to get the mc to change to the frame without the first dragable object sticking inside it.
:if you get what i mean


Angry

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 02:36 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

sorry to double post :(

here a little pickha to explain.

sit on top of an mc?


None

Stives1111

Reply To Post Reply & Quote

Posted at: 8/10/07 02:38 PM

Stives1111 EVIL LEVEL 06

Sign-Up: 09/09/06

Posts: 293

post the script i cant read that but your graphics look good.


Resigned

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 02:41 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

onClipEvent (load) {
startX = this._x;
startY = this._y;
}
onClipEvent (mouseDown) {
if (_root.drag1.hitTest(_root._xmouse, _root._ymouse)) {
_root.draggedDrag1 = true;
}
}
onClipEvent (enterFrame) {
if (_root.draggedDrag1) {
_root.drag1._x = _root._xmouse;
_root.drag1._y = _root._ymouse;
}
}
onClipEvent (mouseUp) {
if (this.hitTest(_root.hit1)) {
_root.draggedDrag1 = false;
_root._root.hit1.nextFrame();
_root.drag1._x = startX;
_root.drag1._y = startY;
} else {
_root.drag1._x = startX;
_root.drag1._y = startY;
_root.draggedDrag1 = false;
}
}

the script works fine.....its just the other part


Resigned

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 03:11 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

oooor instead of draggin it out does any know how to say:

if "hit1" = frame 2 when clicked on the button called "cracked tile" the cracked tile becomes frame 2 (in its mc)

in AS.


None

Stives1111

Reply To Post Reply & Quote

Posted at: 8/10/07 03:12 PM

Stives1111 EVIL LEVEL 06

Sign-Up: 09/09/06

Posts: 293

Im sorry i dont know..i just tried a couple of things but they didnt work


Crying

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 04:07 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

ok then new question.
:this is getting annoying
now does anyone know how to get the 1st mc to drag into the second and stop there. and it can be dragged out at a different frame?

(

Crying

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 04:57 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

seriously, does noone know?


None

Joelasticot

Reply To Post Reply & Quote

Posted at: 8/10/07 05:02 PM

Joelasticot EVIL LEVEL 33

Sign-Up: 02/14/03

Posts: 818

I can help but before I must be sure I understand correctly;

The hammer is a draggable item, and you want it to stick to one of the boxes when it's dragged there, right?

If that is so, try this (with inventory slots named hit1, hit2 - hit5) :

onClipEvent(load){
var initx:Number = _x;
var inity:Number = _y;
var target:String = "this";
var drag:Boolean = false;
//target will be the MC on which the draggable item will stick
//unless it is being dragged
}
onClipEvent(enterFrame){
if(drag){
_x = _root._xmouse;
_y = _root._ymouse;
}else{
_x = _root[target]._x;
_y = _root[target]._y;
}
}
onClipEvent(mouseDown){
if(this.hitTest(_root._xmouse, _root._ymouse)){
initx = _x;
inity = _y;
drag = true;
_root[target].taken = false;
target = "this";
//when dragging starts, it sets the "taken" variable of its
//previous target to false, so it can hold another item
}
}
onClipEvent(mouseUp){
drag = false;
for(i:Number = 0; i <= 5; i ++){
if(this.hitTest(_root["hit"+i]) && !_root["hit"+i].taken){
target = "hit"+i;
_root["hit"+i].taken = true;
break;
//scroll through hit1 to hit5 -> if it touches it, and it's
//not taken, then set this as target and stop loop.
}
}
if(target == "this"){
_x = initx;
_y = inity;
//if it did not touch an inventory slot, reset position
}
}

This code, when applied to a MC, will make it behave as a draggable item

If that's not what you need feel free to ask

s=0;p=0;onEnterFrame=function(){
s+=(25-p)/20;p+=Math.ceil(s);o="";
for(i=0;i<p;i++){o+=" ";};trace(o+"joelasticot");}


Kissing

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 05:11 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

OMG THANKS!!!! i'v been at this for ever THAT WORKED!!!!!

:...

but one question... see my original script would i put that unders yours except change hit1 to ,say, broken tile so when you drag the hammer to the broken tile it will make the broken tile go to the second frame to i could take another item out of there.... or is that wrong?

:THANKS!!!


Crying

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 05:14 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

...oh...wait...when i go to another frame the hammer disapears......


None

Joelasticot

Reply To Post Reply & Quote

Posted at: 8/10/07 05:19 PM

Joelasticot EVIL LEVEL 33

Sign-Up: 02/14/03

Posts: 818

At 8/10/07 05:11 PM, biskits wrote: but one question... see my original script would i put that unders yours except change hit1 to ,say, broken tile so when you drag the hammer to the broken tile it will make the broken tile go to the second frame to i could take another item out of there.... or is that wrong?

Yeah it's possible, dunno if our two codes mixed would turn out well, but I can edit the one I gave you a bit so that you can easily add new items to the game and make them interact with certain stuff

Start by adding this to the onClipEvent(load) of the hammer :

var correct:String = "brokenTile";

With this variable you'll be able to define where items should go, brokenTile being your tile's instance name

Now add this to the onClipEvent(mouseUp), just after the for() loop :

if(this.hitTest(_root[correct])){
target = correct;
_root[correct].nextFrame();
}

In other words, when you stop dragging the item, it'll check if it's touching the place where it should be used. If so, then this place will be its new target and the other movie clip will go to the next frame

s=0;p=0;onEnterFrame=function(){
s+=(25-p)/20;p+=Math.ceil(s);o="";
for(i=0;i<p;i++){o+=" ";};trace(o+"joelasticot");}


None

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 05:30 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

if you move frame the hammer disapears! so how would you say : check if you have dragged theh hammer(drag1) into the inventory and make sure it stays there on each frame except from when you are using it & have used it?


Crying

biskits

Reply To Post Reply & Quote

Posted at: 8/10/07 06:54 PM

biskits DARK LEVEL 13

Sign-Up: 07/14/06

Posts: 390

no-one?


Sleeping

Stives1111

Reply To Post Reply & Quote

Posted at: 8/10/07 07:50 PM

Stives1111 EVIL LEVEL 06

Sign-Up: 09/09/06

Posts: 293

The reason why is most like becuase of this lets say your time line looks like this..

1 2 3 4 5 6
|_|_|_| | |_|

Notice the break? Well lets say the movie clip that had your hammer on it was in 1-3 and 6. If you go from 1 to 6 or anything past the break it will reset to its orignal form on its first frame. At least i thinks thats whats happening. To fix this paste it on all the frames in-between but off stage if you dont want it on stage. At least that might be whats wrong im not sure though but i had the same problem with one of my games.


Misunderstood

Stives1111

Reply To Post Reply & Quote

Posted at: 8/10/07 07:52 PM

Stives1111 EVIL LEVEL 06

Sign-Up: 09/09/06

Posts: 293

Sorry about double posting but also make sure they all have the same instance names if you have them all the frames inbetween.


All times are Eastern Daylight Time (GMT -4) | Current Time: 12:59 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!