00:00
00:00
Minix07
what is goodie in da hoodie gangalang?

ima dude, dude

Human

Highland High School

was british land

Joined on 1/13/24

Level:
8
Exp Points:
656 / 710
Exp Rank:
> 100,000
Vote Power:
5.04 votes
Rank:
Police Sergeant
Global Rank:
8,100
Blams:
218
Saves:
973
B/P Bonus:
12%
Whistle:
Normal
Medals:
255
Supporter:
15d

Making a click n' point game using AS3 | Step 6. More rooms

Posted by Minix07 - 3 hours ago


Step 6. More rooms

This one is simple: make an arrow or something that you click on to move onto a different room. Turn to movieClip and give an instance name. Do the same type of code that is used for the start button.


AD_4nXfcpoRMS5jzKWz9cmzQVeVFL_ZLH3Gd7Ppf6dSISDYkR-JznFZ4rrJkKovy41q99oSu_82ayaRzezUZjxHL272zFrf5miA_wwsftCGWKYtwUwAfl1lD7XVBg6Sv8RNuxx7QVI3Knw?key=lYln-58pvChvGvHg5Z5QrA

(probably the ugliest thing I’ve ever made in Flash)


To make another room, go inside the game MovieClip and create an empty frame while keeping the inventory.


AD_4nXcbSkSd1Z3DaRgiyN6UF8YSuCdJqPO_CTMwpUeTq68jxud9_OaYUPkZMRYzCR6ppNcziJRrxBLL4vG9sTXdRFJC_EeMw0iDW0ogkxogYCvCTISAg683CJ-BbETF1toDwIkrJBWV?key=lYln-58pvChvGvHg5Z5QrA

(Zoomed to see the frame labels better)


Now, on this new frame (with a label), draw whatever the next room is going to be and repeat the same steps as before.


Draw

AD_4nXcCanWEGTaNFZHlspa1tli9mUlRtOIz7fZsTmvmY2VezqZM8bQwH3Vnh13ialOVlnUmJTysvCWQZXmYa26i1iWEr5wGUQUJSnQHj5YDhQbjdW22-UWsdV74OoYW1X-9Elv9ZsKUUA?key=lYln-58pvChvGvHg5Z5QrA


Turn to the symbol twice

AD_4nXc7IHhuqwHg8AoiwEEHGfCM3d7LNmy_n874IL24pAWyEo5-Rbp5d7WN2Qafmk4vlXQ3FVG_-BuiEw2emc4gHfedQifVr1A5BZ165Wwl2hXsi2ytOwAer1vKaTstxQjH0GzxYyGcZw?key=lYln-58pvChvGvHg5Z5QrA


AD_4nXeXFGXNwo7AF0OIeJ_JX-8gVoJV4RZ6Ixo0qsSakaRMTm2dCfAlnyTqlqF2fKfLaUETNWGKs4o0m995B9udoLrjgmn6dEfKFWAF1eQv_4iC2kibxYc3EKjR7Ab27eS4UEMiqVCXgA?key=lYln-58pvChvGvHg5Z5QrA


Then, back in the first room’s code:


this.arrowHallway1.addEventListener(MouseEvent.CLICK, enterHallway1);

function enterHallway1(event:MouseEvent):void {
	Object(root).game.gotoAndStop(“hallway1”);
}

Want the arrows to have a fancy hover like the ones in Riddle School? First, convert your arrow into a symbol so you can animate it growing in size (make sure to call the new one the same thing as the old one and call the old one nothing)


Make the old arrow’s instance name EMPTY


AD_4nXdo30LUi-9cvkkO6sQq3igArOMIlsVo3uQcG8J9zQXIB2Iym11z2KsNBwNKEqMs99kiVcPW5h9qpWQsnHlZRUCqEo2VlB1f8EbBE19_G-vwai60rmIRVbWOQNvBMVinvhwmSn9VoQ?key=lYln-58pvChvGvHg5Z5QrA


The new arrow’s instance name should be the same as the old one.


AD_4nXfrk4dupawCcg_zlJBVygW1TrX7k_0CcN4RvNp-scFarp2X-d6Yy9eJLMmst24P47mfB6RoDm6jBLU4AbAulOa7qP-_7_K_xmKF4teSQo4hoErzWWsyq3q60KcavEwANxBSlJQj?key=lYln-58pvChvGvHg5Z5QrA


Give the arrow an animation. I gave it a basic growing animation with a glow.


AD_4nXdH9vkmf-I8170WqH8wMjX6foc7EuJ-UrMOgQjD3p6VhwpuaEZqgvVRajvo61DDFIQPeMBVQcMiuxE9XUFENdZSv3EAIO5KpCFip0j7QYv9DCfODG4NaQHmHUPWKwA4VC01a_2IlA?key=lYln-58pvChvGvHg5Z5QrA


Back in the room code, make another eventListener, but this time make it an ENTER_FRAME


this.arrowHallway1.addEventListener(Event.ENTER_FRAME, hoverarrowHallway1);

function hoverarrowHallway1(event: Event): void {

}

We will be using a function called hitTestPoint(); It has 3 inputs: an X input, a Y input, and a ShapeFlag that doesn’t matter right now. What Flash does is check to see if the object X and Y points match up to the inputs X and Y points, hence the name hitTestPoint. It needs to be spelled exactly like this, and it should turn to a different color whenever you type it correctly.


this.arrowHallway1.addEventListener(Event.ENTER_FRAME, hoverarrowHallway1);


function hoverarrowHallway1(event: Event): void {

if (this.arrowHallway1.hitTestPoint(stage.mouseX, stage.mouseY, true)) {

this.arrowHallway1.nextFrame();

} else {

this.arrowHallway1.prevFrame();

}

}


Our inputs will be the player's mouse cursor and the true means we check the actual pixels of the object, instead of its bounding box (false). If you care, and are a nerd, you can read more about it here: DisplayObject - ActionScript 3.0 Language Reference


What this function does is, every frame, it will check if the mouse’s x and y points are touching the arrow's points. If it does, then do whatever is inside the brackets; if it doesn't, do the else. In this case, if they are touching, go to the next frame. Since this is being checked every frame, it will look like it's growing until it’s reached its last frame. Once they are no longer touching, it will go back a frame, making it look like it’s shrinking until reaching the first frame.


If you don’t want to do this, you can just make the arrow a simple button. 


Next, it’s time to discuss something that you have to face one way or another.


Tags:

Comments

Comments ain't a thing here.