Coin pluz Forum

Coin pluz Forum.

You are not logged in.

#1 2020-09-14 11:45:47

Rosaline08
Member
From: United States, West Palm Beach
Registered: 2020-09-14
Posts: 1

-115); } function addBumper(xLocation:int

Search.
Bookmark the.
by               As I announced in the , I am extremely busy right now.
Luckily for you, a member of  the community  has already stepped up and written a Part 13 for this side scrolling tutorial.
In this tutorial, you’ll learn to create “bumper” objects for y our enemies  to interact with, which will let them patrol back and forth.
You’ll also look for collisions between the player and the enemies, so you can take damage in your game.
Cool.
I’ll hand it over now to the newest guest writer around here,  (thanks.

Ed!)   Ben covered creating enemies and making them disappear when they’re shot in

so in lucky lesson 13, in this guest tutorial, I’ve picked up where the last lesson left off in the side scrolling platform game.
Once you’ve created the bumper square, select the bumper, .

And convert it to a Movie Clip symbol

As mentioned in the last lesson, .

Go to the Advanced section to link this object to the “Bumper” class

If you need a refresher on what all the settings are for, refer to.
package {     import  flash .display.
MovieClip;     import  flash .events.
Event;     public class Bumper extends MovieClip{          public function Bumper(xLocation:int, yLocation:int) {             //  constructor  code             x = xLocation;             y = yLocation;              addEventListener(Event.
ENTER_FRAME, bumperloop);         }          public function bumperloop(e:Event):void{             //code here         }     } }       var bumperList:Array = new Array();    function addBumpersToLevel1():void {     addBumper(500, -115);     addBumper(740, -115); }    function addBumper(xLocation:int.

YLocation:int):void { var bumper:Bumper = new Bumper(xLocation

yLocation); back.addChild(bumper); bumperList.push(bumper); }      package {     import flash.display.
MovieClip;     import  flash .events.
Event;public class Enemy extends MovieClip {          private var xSpeedConst:int = 2;         private var flip:int = 1;          public function Enemy(xLocation:int, yLocation:int) {             //  constructor  code             x = xLocation;             y = yLocation;             addEventListener(Event.
ENTER_FRAME, loop);         }           public  function loop(e:Event):void {             if ((flip%2) == 1){                 x += xSpeedConst;             } else if((flip%2) == 0){                 x += (-xSpeedConst);             }         }          public function removeSelf():void {             trace("remove enemy");             removeEventListener(Event.
ENTER_FRAME, loop);             this.parent.removeChild(this);         }           public  function changeDirection():void{             trace("x ="+x);             flip++;         }     } }        //corralling the bad guys with bumpers if (enemyList.length > 0){ //enemies left in the enemyList.
for (var k:int = 0; k < enemyList.length; k++){ // for each enemy in the enemyList         if (bumperList.length > 0){             for (var h:int = 0; h < bumperList.length; h++){ // for each bumper in the List                 if ( enemyList[k].hitTestObject(bumperList

) ){                     // trace("hit bumper");                     enemyList[k].changeDirection();                 }             }         }     } }      //player and enemy collisions if (enemyList.length > 0){ //enemies left.
For (var m:int = 0; m < enemyList.length; m++){ // for each enemy in the enemyList         if ( enemyList[m].hitTestObject(player) ){             trace("player collided with enemy");             //code to damage player goes here             enemyList[m].removeSelf();         }     } }      function addBumper(xLocation:int.
[h]YLocation:int):void {     var bumper:Bumper = new Bumper(xLocation

yLocation);     back.addChild(bumper);     bumper.visible = false;     bumperList.push(bumper); }       Source Files:.
This entry was posted in , , ,  and tagged , , , , , , , , , , , , ,.
49 comments on “”.
mojmon.
immrsam                                      nitacawo               Just finished tuts and had some pain to remove them myself.
The proper way to remove enemies and bumpers due to array system would be.
creating a function.
Its not explained here but if you followed tuts you would probably try ++ like Tyler and I did first.
It wont work properly due to array system.
You can read more info here.
tyler                                      tyler                                       Nick.
Nick.
tyler.
TheLibyan.
Allan.
RedDevil.
Will Mahan.
Ciara.
Rick.
Nico B                                      jake.
Kerta L.
Colt K.
FenderFalcon.
Jonathan Grenier.
Jonathan Grenier.
Bex.

Sampada               Here is the game i designed using this tutorial… have a try…

Laura.
Will Mahan.

Broc                                      Isaac Clarke

JoeFrank.
Isaac Clarke.
Avery.
Manny.
Matt.
I made an  animated  enemy and then hitTestObject not work when fired at the enemy.
How to fix it.
I want the enemy to be animated.
I also noticed that in your example, sometimes the protagonist falls into the earth.
How to fix it.
And I would like to learn how to add different enemies.
Thank you.
At least if you know the answer to one of the questions, contact me at my e-mail or comment here.
flash.
Flash.

Rick                                       Luanua

Leave a Reply.
Enter your comment here.
Email                  Name                 Website                                                            You are commenting using your WordPress.com account.
(  /     )                                                            You are commenting using your Google account.
(  /     )                                                            You are commenting using your Twitter account.
(  /     )                                                            You are commenting using your Facebook account.
(  /     )                                                                           on the App Store for relaxing bubble-popping and 50 characters to unlock.

On the App Store for dozens of brain-twisting puzzle challenges

on the App Store for cute, reflex-based fun.
Monthly Archives        Select Month    July 2013  (1)   June 2013  (1)   May 2013  (2)   November 2012  (1)   September 2012  (2)   July 2012  (1)   June 2012  (2)   May 2012  (1)   April 2012  (2)   March 2012  (1)   February 2012  (4)   January 2012  (3)   November 2011  (2)   September 2011  (4)   August 2011  (3)   March 2011  (3).
Post to                                                                                         bloggers like this:.

Offline

Board footer

Powered by FluxBB