A Flash Developer Resource Site

Results 1 to 20 of 214

Thread: The elusive hitTest explained

Hybrid View

  1. #1
    Junior Member
    Join Date
    Nov 2002
    Posts
    13

    Will this work with...

    this works really nicely for art-based RPG's where you go from room to room, but is there any way to modify the code to make a large outdoor map that will start to scroll up/down/left/right as soon as the "hero" gets to the midpoint of the screen? If you still don't know what I'm talking about here's an example someone did that I'm trying to implement into my RPG engine, but i'm stumped on how to do it using the current script setup: http://www.geocities.com/mclelun/rpg.html

    Any help would be appreciated. Thanx.
    -NeotiK

  2. #2
    Senior Member
    Join Date
    Jun 2006
    Location
    USA
    Posts
    101
    Quote Originally Posted by NeotiK
    this works really nicely for art-based RPG's where you go from room to room, but is there any way to modify the code to make a large outdoor map that will start to scroll up/down/left/right as soon as the "hero" gets to the midpoint of the screen? If you still don't know what I'm talking about here's an example someone did that I'm trying to implement into my RPG engine, but i'm stumped on how to do it using the current script setup: http://www.geocities.com/mclelun/rpg.html

    Any help would be appreciated. Thanx.

    Its called art based scrolling.....

    Or you can use tiles

    check the knowledgebase

  3. #3
    Member
    Join Date
    Jun 2007
    Posts
    67
    hello everyone.
    i am makin a top down art based rpg game, and i have this code:
    code:

    onEnterFrame=function(){
    if(Key.isDown(Key.UP)){
    if(! game.map.limit.hitTest(game.player._x, (game.player._y + speed), true)) {
    game.map._y += speed
    }
    }
    if(Key.isDown(Key.DOWN)){
    if(! game.map.limit.hitTest(game.player._x, (game.player._y + speed), true)) {
    game.map._y -= speed
    }
    }
    if(Key.isDown(Key.LEFT)){
    if(! game.map.limit.hitTest((game.player._x + speed), game.player._y, true)) {
    game.map._x += speed
    }
    }
    if(Key.isDown(Key.RIGHT)){
    if(! game.map.limit.hitTest((game.player._x + speed), game.player._y, true)) {
    game.map._x -= speed
    var po_x = game.player._x
    }
    }
    }



    i have some white circle movie clips (instance name limit) in a movie clip called map.
    when it hits the limit movie clip i want it to stop, the problem with taht is it scrolls into the circle a bit before stoping (the player and the object partly overlap) and its easy to get stuck.
    I want it to stop as soon as one edge ofd the player hits one edge of a wall.

    tahts the first thing

    the 2nd thing is that i have 7 or something of them circle movie clips in the map movie clip (all instanced named limit), and it only works for one. I need it so i can make many diffrent walls and boundaries of diffrent shapes and locations.

    help is apreciated! ive been looking for days.

  4. #4
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,377
    Quote Originally Posted by ThrashBoy
    hello everyone.
    i am makin a top down art based rpg game, and i have this code:
    code:

    onEnterFrame=function(){
    if(Key.isDown(Key.UP)){
    if(! game.map.limit.hitTest(game.player._x, (game.player._y + speed), true)) {
    game.map._y += speed
    }
    }
    if(Key.isDown(Key.DOWN)){
    if(! game.map.limit.hitTest(game.player._x, (game.player._y + speed), true)) {
    game.map._y -= speed
    }
    }
    if(Key.isDown(Key.LEFT)){
    if(! game.map.limit.hitTest((game.player._x + speed), game.player._y, true)) {
    game.map._x += speed
    }
    }
    if(Key.isDown(Key.RIGHT)){
    if(! game.map.limit.hitTest((game.player._x + speed), game.player._y, true)) {
    game.map._x -= speed
    var po_x = game.player._x
    }
    }
    }



    i have some white circle movie clips (instance name limit) in a movie clip called map.
    when it hits the limit movie clip i want it to stop, the problem with taht is it scrolls into the circle a bit before stoping (the player and the object partly overlap) and its easy to get stuck.
    I want it to stop as soon as one edge ofd the player hits one edge of a wall.

    tahts the first thing

    the 2nd thing is that i have 7 or something of them circle movie clips in the map movie clip (all instanced named limit), and it only works for one. I need it so i can make many diffrent walls and boundaries of diffrent shapes and locations.

    help is apreciated! ive been looking for days.

    You don't need to post this twice. I just answered your question here .
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  5. #5
    Member
    Join Date
    Jun 2007
    Posts
    67
    sorry
    code:
    for (i=0; i<8; i++) {
    onEnterFrame=function(){
    if(Key.isDown(Key.UP)){
    if(! game.map["limit"+i].hitTest(game.player._x, (game.player._y + speed - playerhs), true)) {
    game.map._y += speed
    }
    }
    if(Key.isDown(Key.DOWN)){
    if(! game.map["limit"+i].hitTest(game.player._x, (game.player._y + speed + playerhs), true)) {
    game.map._y -= speed
    }
    }
    if(Key.isDown(Key.LEFT)){
    if(! game.map["limit"+i].hitTest((game.player._x + speed - playerhs), game.player._y, true)) {
    game.map._x += speed
    }
    }
    if(Key.isDown(Key.RIGHT)){
    if(! game.map["limit"+i].hitTest((game.player._x + speed + playerhs), game.player._y, true)) {
    game.map._x -= speed
    }
    }
    }
    }



    i now have another issue (i know that codes not very good above, because i just tryed to make it work) and i was wondreing if that was somewhat close to what i should be doing to make mutiple walls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center