-
-
Sorry for the spam.
See the problem here (do not forget to click on the game to work): http://www.fastswf.com/xbianPQ
-
Senior Member
the code is correct, but you have to do it for *every* coin. just pasting the code above will only work for one of them. you could put this into the coin mc, doing this.onEnterFrame = ..., instead.
-
Hey man.. I've done it.. but somehow.. do not "corrupt" game? For example, start getting lag in the game?
-
Senior Member
yes, of course, because hit test is expensive operation. now you're looking into optimizing this, for example running the test only if the coin is visible on the screen, or within 100 pixels from the hero
-
Nice! Any idea about how to make this? Example code or a link? c.c
-
Senior Member
assuming coins are also in the _root, try changing
PHP Code:
if (_root.player_mc.hitTest(this))
to
PHP Code:
if ((Math.abs(_root.player_mc._x - this._x) < 100) && _root.player_mc.hitTest(this))
-
Senior Member
oh, another idea is that as2 might be upset by the number of onEnterFrame handlers this creates. so, if the above hitTest guess is not correct, try creating onEnterFrame on player instead and loop over coins there.
-
Nice code man, if I want that this code also works with y, just replace the x or need to make any more changes?
The other idea is awesome, I will test it.
-
Hey... sorry for the resurrected the topic, but I was still having trouble about it. I've searched various forms of loop the coins but found nothing. Anyone has any idea?
-
Senior Member
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|