Character moving

hi guys
i have  3 classes in the library (external classes) and 1 document class called Main
in HERO class character should move but it not
here more details there is document class called (Main) and then class in lib called (MAINMAP1) inside this class 2 classes the tree and hero
in the last game the code work well and its the same excpet ( there is only 1 document class) and nothing else  but here 4 classes
and here are the codes
MAINMAP1 class
package
import flash.system.System;
import flash.system.fscommand;
    import flash.display.MovieClip;
import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.Stage;
public class MAINMAP1 extends MovieClip {
    var vx:int = 0
    var vy:int = 0
  public function MAINMAP1(){
    addEventListener(Event.ADDED_TO_STAGE, onAdded)
  public function onAdded (event:Event):void  {
tree1 class
package{
    import flash.system.System;
import flash.system.fscommand;
    import flash.display.MovieClip;
import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.Stage;
    public class tree1 extends MovieClip{
        public function tree1 (){
                addEventListener(Event.ADDED_TO_STAGE, onAdded)
                public function onAdded (){
                                              addEventListener(Event.ENTER_FRAME, onEnterFrame);
    public function onEnterFrame(event:Event){
HERO class
package{
    import flash.system.System;
import flash.system.fscommand;
    import flash.display.MovieClip;
import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.Stage;
    public class HERO extends MovieClip{
    private var vx:int = 0;
        private var vy:int = 0;
        public function HERO (){
                addEventListener(Event.ADDED_TO_STAGE, onAdded)
                public function onAdded (event:Event):void  {
      gotoAndStop(3)
          addEventListener(Event.ENTER_FRAME, onEnterFrame);
        stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
            stage.addEventListener(KeyboardEvent.KEY_UP,onKeyUp);
    public function onEnterFrame(event:Event){
        x += vx
        y += vy
    public function onKeyDown(event:KeyboardEvent){
        if (event.keyCode == Keyboard.LEFT){
            gotoAndStop(2)
            vx = -5
                if (event.keyCode == Keyboard.RIGHT){
                    gotoAndStop(1)
                                vx = 5
        if (event.keyCode == Keyboard.DOWN){
            vy = +5
            gotoAndStop(6)
if (event.keyCode == Keyboard.UP){
            vy = -5
public function onKeyUp(event:KeyboardEvent){
            if (event.keyCode == Keyboard.LEFT ||event.keyCode == Keyboard.RIGHT ){
                vx= 0;
if (event.keyCode == Keyboard.UP ||event.keyCode == Keyboard.DOWN ){
                vy= 0;
THE DOCUMENT CLASS (Main)
package  {
    import flash.system.System;
import flash.system.fscommand;
    import flash.display.MovieClip;
import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.Stage;
    public class Main extends MovieClip {
        var mainmap1:MAINMAP1 = new MAINMAP1;
        public function Main() {
            addChild(mainmap1);
i hope you guys can help because i tried to move the hero but i couldn.t the whole problem from the HERO class (i guess)
thank you

I don't see the HERO class in any code you show, and if there is no instance of it on the stage, then you have no HERO object to move.  Nothing is creating one and there is none to begin with otherwise.
What you might try to help you understand and get this working is to create a new fla file and create a movieclip on the stage and assign it the class name HERO via its linkage.  Then, with the HERO class file in the same folder as that fla, run the fla.  YOu should see the HERO object moving with your keyboard controls.
Then, remove that object from the stage and in the first frame use... var hero:HERO = new HERO();  addChild(hero);   ... and you should see the same result of being able to move a dynamically created instance of HERO around with the keyboard.
Then see how to work this into the other file you are wroking on.

Similar Messages

  • Enquiry about character moving and rotating diagonally on tiled map....

    I have been able to make my character move up down the map and not going thru the wall. I also have able to move diagonally but it move faster than the up and down speed. Also i can't figure out how to rotate the character when it moved diagonally.....
    Any hints or help?

    rotate() should always be accompanied with appropriate translate().
    See:
    http://java.sun.com/docs/books/tutorial/2d/TOC.html
    http://www.adtmag.com/java/articleold.aspx?id=1241
    http://www.apl.jhu.edu/~hall/java/Java2D-Tutorial.html
    And, never mix AWT components with Swing ones.
    Use JPanel instead of Canvas.
    Use also standard drawing/painting technique shown above URSs.

  • Help importing a .swf file from Flash CS5.5 to After Effects CS5.5

    I am working on animating a person in flash.  I have a main timeline and then a timeline inside of a symbol so I can move
    the characters facial features (eyebrows and mouth etc) apart from moving his entire body.
    I want to have multiple scenes so I am importing all of the .swfs into After Effects and putting them together. 
    However, when I import the .swf into After Effects, it only plays what occurs in the main timeline
    and not the timeline inside of the symbol, so it is just the character moving without the facial movements.
    Is there a way to fix this or a better program to import the .swfs into and make the video?
    Thanks in advance.

    Here's the note from After Effects Help aboutt he limitations to SWF import:
    SWF (continuously rasterized) Note:  SWF files are imported with an alpha channel. Audio is not retained. Interactive content and scripted animation are not retained. Animation defined by keyframes in the main, top-level movie is retained.
    The limitation that you noticed---that only animation in the top-level timeline is retained---is not one that can be worked around without changing how your animation is set up in Flash.

  • Touch Events: How can I check for a button being pressed while another button is being held down?

    Hello,
    I'm trying to check for a button being pressed while another is down through Touch.  In my case, I' m making a game and I need for a button to make the character jump.  However, when I hold down right, I notice that the jump button becomes somewhat unresponsive and I have to press it twice or more to get it to trigger, as opposed to just pressing the jump button by itself with nothing held down which works fine.  I'm testing this on my Motorola Droid 2.
    Here is some of my code that demonstrates text instead of my character moving around:
    package  {
         import flash.events.TouchEvent;
         import flash.ui.Multitouch;
         import flash.ui.MultitouchInputMode;
         public class Document extends MovieClip {
               Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
               private var controls:BottomBar;
               private var debugText:String;
               public function Document() {
                    addIngameGUI();
               private function addIngameGUI(){
                    controls = new BottomBar();
                    controls.y = stage.stageHeight - controls.height;
                    addChild(controls);
                    controls.aBtn.addEventListener(TouchEvent.TOUCH_BEGIN, testBtns);
                    controls.bBtn.addEventListener(TouchEvent.TOUCH_BEGIN, testBtns);
                    controls.leftArrow.addEventListener(TouchEvent.TOUCH_BEGIN, testBtns);
                    controls.rightArrow.addEventListener(TouchEvent.TOUCH_BEGIN, testBtns);
             private function testBtns(event:TouchEvent){
                   debugText.text = event.target.name;
    What am I doing wrong?  Is there a better approach?
    Thank you in advance.

    Hello,
    I'm trying to check for a button being pressed while another is down through Touch.  In my case, I' m making a game and I need for a button to make the character jump.  However, when I hold down right, I notice that the jump button becomes somewhat unresponsive and I have to press it twice or more to get it to trigger, as opposed to just pressing the jump button by itself with nothing held down which works fine.  I'm testing this on my Motorola Droid 2.
    Here is some of my code that demonstrates text instead of my character moving around:
    package  {
         import flash.events.TouchEvent;
         import flash.ui.Multitouch;
         import flash.ui.MultitouchInputMode;
         public class Document extends MovieClip {
               Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
               private var controls:BottomBar;
               private var debugText:String;
               public function Document() {
                    addIngameGUI();
               private function addIngameGUI(){
                    controls = new BottomBar();
                    controls.y = stage.stageHeight - controls.height;
                    addChild(controls);
                    controls.aBtn.addEventListener(TouchEvent.TOUCH_BEGIN, testBtns);
                    controls.bBtn.addEventListener(TouchEvent.TOUCH_BEGIN, testBtns);
                    controls.leftArrow.addEventListener(TouchEvent.TOUCH_BEGIN, testBtns);
                    controls.rightArrow.addEventListener(TouchEvent.TOUCH_BEGIN, testBtns);
             private function testBtns(event:TouchEvent){
                   debugText.text = event.target.name;
    What am I doing wrong?  Is there a better approach?
    Thank you in advance.

  • Probably the mother of all stupid display questions...

    I just bought a Gateway 22" widescreen for my PowerMac. Max resolution is 1680 by 1050 which is the default the Mac set it to (DVI connection btw). I was messing around playing UT2004 with this new display. My question is this...would the display or increase in the resolution somehow AFFECT actual gameplay? Specifically I noticed that once in a while, my character will stop moving forward, I have to let off on the key and press it down again to get my character moving again. I only noticed this AFTER upgrading my display, I used to have a Samsung 17" LCD display. BTW, my keyboard is a MIcrosoft Wireless Mac desktop. Like I said, didn't have problems until the display was upgraded. Any suggestions as to what the problem might be?
    Cliff Notes: upgraded display to 22" Widescreen, Graphics cart is a Radeon X800 XT, try to play UT2004, character stops moving forward intermittently. Didn't have problem before...any relation? Thanks.

    There should only be issues if you have also increased the resolution in the game itself (because the graphics chip has to work harder). Are you able to check (or lower) the resolution within the game?
    Matt

  • URGENT: Collision Detection In Tiled Map

    HELP!!!!! I am creating a tile map of size 32*32. And the character image size is also 32*32. Now i am stuck in making collision with the walls. I have tried my own method but to no avail. Has anyone tried to doing collision detection? Need a simple logic method to detect the collision...
    (Using keyevent to control the character moving around)
    Pls I really appreciate your help!!!!!!!
    Thanks.....

    I assume you have some way of knowing that you need to display a wall tile on the map, so before you move a particular direction check to see if the square you will move to is an acceptable move (no wall, door, mountain, water etc). If it is unacceptable play a little sound or display a message, otherwise do the move.

  • Best way to do a tile-based map

    Hello everybody-
    This should be a simple thing but I just can't get it to work. I'm making a tile-based top-down online rpg (application, not applet), and I pretty much have most of it done except I can't get the map to display and scroll right. i will admit that java graphics isn't really my thing, but i just can't get it. Its been so frustrating that i actually quite develpment on my game and quit for awhile, but i decided to try again. What I have is an array if images that make up the map, and then i manipulate the array depending where the character is so i only draw the tiles necessary. what i want to do is to combine all the tiles i need for the particular position, draw that image to the screen (so i don't have to draw each tile individually to the screen). then i could move that large image depending where the character moved, and add tiles to it depending on which way the character moves. I just can't get it to work however. I've looked at double-bufferning posts and that gave me some ideas, but not enough for my particular situation. if anybody has any experience in this i would be more than greatful. thank you

    I know exactly what you are talking about, I had your problem a while back when I was doing mobile phone games.
    To reduce the number of cell draws needed, cells were only drawn when at the edges of the view area. (all other cells were maintained from the previously drawn frame.)
    It gets pretty complicated, but it will work - stick with it.
    I would post some code - but I don't have it anymore - and it was pretty specific to J2ME MIDP API (java mobile phone).
    p.s. When I did it, I had to include several additional optimisation, these made it incredibly complex :(
    I will try to describe it, but without pictures, It will probably be in vain. (don't worry if you don't understand it :P)
    here is the summary of the logic :-
    the backbuffer had dimensions SCREEN_WIDTH+CELL_WIDTH*2, SCREEN_HEIGHT+CELL_HEIGHT*2 (I effectively had a border that was CELL_WIDTH wide, and CELL_HEIGHT tall.)
    this meant new cells only had to be drawn every time the view area passed over a cell boundary.
    however, doing this, meant it was super smooth until it hit a cell boundary, at which point it had to draw all the cells in the newly exposed column and/or row - which caused a jerk.
    To get around this, I devised a speculative rendering, where by the next column/row was pre-rendered over a series of game frames.
    (each column/row had its own buffer into which the pre-rendering was done)
    On average 2-4 times as many edge cells had to be rendered than needed, but, because the camera moved slowly, this could be distributed over approx. 10 game frames.
    By distributing the rendering of the edge cells over a number of game frames, I hoped to remove the jerk experienced as the camera crossed a cell boundary.
    The system worked... ish... but I never finished it :(
    basically, these were crazy optimisations that were only necessary because I was developing for mobile phones.
    On mobile phones the speed of rendering is relative to the number of draw calls, NOT the actual area of the screen being repainted.
    e.g.
    fillRect(0,0,50,50)
    fillRect(0,50,50,50)
    will take almost twice as long as
    fillRect(0,0,100,100)
    even though you are only painting 1/2 the area.

  • How capable is flash?

    Greetings.
    Me and a friend are developing a videogame using Macromedia
    Flash MX 2004. The videogame is featuring plenty of 3D art imports
    in the form of JPGs. Since the videogame aims at being similar to
    an RPG (Role Playing Game), it features several heroes. Each heroe
    (done in 3D but exported to .GIF files) can walk in at least four
    directions, top, right, bottom, left. Each direction features 7
    frames of the character moving. That means there are 28 frames in
    total per character. There are 7 characters, so the total frames
    will go up to 7 * 28 , totalizing 196 frames total.
    I have discovered I have two options and both seem to be
    valid:
    1. I can import the jpgs/gifs and trace them and locate each
    image in the proper frame.
    OR
    2. I can import transparent .GIFs and locate them in the
    proper frame.
    In principle, both ways seem to work nicely, and the quality
    seem similar. However, in terms of memory and Flash stability,
    which method would you recommend? Will flash prefer one method over
    the other?
    Though it runs fine for now, I ask this question because I
    don't want the videogame to experience sudden hangs later on.
    Thanks in advance for any answer / reply.

    Use method #3 - png files with transparency. If that is not
    an option open up your gifs in photoshop and convert them to png
    files in there.
    Jpeg and gif files are lossy files, where png files are
    lossless compressed files. You can change the settings of every
    image by adjusting the quality slider on Flash's publish screen.
    This means you can make multiple versions of your game with the
    click of the button (low res to high res) which isn't really an
    option with jpgs or gifs. (Someone let me know if this is
    incorrect.)
    Flash is deeper then you could ever imagine, your main
    stumbling block will be the power of the end users computer.
    Good luck with your game. Making a game in Flash is harder
    then you can imagine...

  • How to animate from a png tile based image file

    Hi all,
    I would like to know is there any way to animate from a tile based .png image file? I have multiple images in 1 png file having slight changes in each image, which if cropped and put into layers one over the other, will give the feel of animation or a character moving or walking etc...
    I want to know can we do that kind of animation in flash as we do it in C++ or Java and how can we do it.
    Any help will be highly appreciated.
    Thank you
    Shanz - Iceheros

    I want to use action script to externally call/access  the png file with url request and url loader and animate the images from the tile based png image file.
    Anybody know how to do this in flash with as3.
    Here is the image for example:
    i want to animate this images and call it externally and access each tile 1 after another.
    Any Help???
    Thanks,
    Shanz - Iceheros

  • Motion tweening a frame-by-frame animation

    Hello,
    I am an experienced animator who is new to using Flash. I need to know how to add a motion tween to an animation that I already made frame-by-frame. The animation will be of a fish blinking as it swims across the stage. I already created the frame animation of the fish blinking, but now I want to motion tween the whole animation (not just one frame) across the stage. However, I cannot figure out how to do this. Is there a way to create a simple animation that uses frame-by-frame animation and motion tweens simultaneously?

    Unfortunately, Adobe let (character) animators down by not developing any of Flash's animation tools since v8 - quite the contrary, the latest incarnation, CC, removed a lot of (quite essential) animation functionality. No more bones (yikes!) or motion curves control.
    A shame, because once Flash was the industry standard app for tv show animation. Not so anymore, though: Adobe dropped the ball in that regard, and mostly focuses on web/mobile apps and games development currently.
    There are two options:
    1) use animator-oriented alternatives like Toonboom and/or Anime Studio Pro (both of which export to flash movies);
    2) download a bunch of plugins, and extend Flash so that its workflow becomes more animator friendly.
    If you are just starting out, I would probably advise you to have at least a cursory look at the alternatives. However, having said all that, Flash can still be an enjoyable environment to animate in, IF you extend it a bit. Unfortunately some workflow may not be CC friendly anymore at this point due to the missing (almost essential) functionality compared to CS6 - you may prefer to work in CS6, depending.
    These will help you extend Flash to become a bit more animator friendly:
    http://cloudkid.com/tools
    http://flash-powertools.com/
    For example, Keyframe Caddy would solve your problem animating an eye by keyframing it in a symbol.
    The guys at flash-powertools created a character animation workflow you may like, which addresses the deficiences of Flash for professional level character animation. They have some nice templates and example character files for you to examine.
    A word of warning: character animation in Flash can become somewhat technical and daunting - in that case a tool like Anime Studio with excellent and easy to use bone tools and proper real(!) animation curves can be truly helpful. These can then be imported into Flash, and edited. Also, both AS and TB have a "real" virtual 3d camera of the scene that makes it easy to create parallax scrolling backgrounds and zoom in/out panning effects.
    Anyway, this is how you would do it in Flash:
    1) install Keyframe Caddy
    2) draw your fish in a cutout-fashion (seperate eye).
    3) convert all the fish elements to a graphic symbol (F8)
    4) double-click the fish symbol
    5) select the eye, and convert to a graphic symbol again
    6) add different drawings for the eye blinking
    7) return to the main stage
    Now you can start animating the fish:
    1) first animate the entire character moving
    2) then after you finish the overall movement, move to the frame you wish to change the eye
    3) double-click the fish character, and select the eye
    4) in KeyFrame Caddy click "load thumbnails". This should load up all the different frames (drawings/states) for that graphic symbol and display them all in the KeyFrame Caddy window
    5) now simply click on the required eye state, and KeyFrame Caddy will automatically create a keyframe for that state.
    6) move the timeline scrubber to the next frame you wish to keyframe eye movement
    7) click on the required eye state in the KeyFrame Caddy window.
    ...and so on! You may have to switch between the main scene and the fish symbol
    Make certain the lengths of both timelines are identical, otherwise the eye animation will start to repeat if it is shorter than the main timeline. Inversely, if the main timeline is shorter than the eye animation, the eye animation will obviously not be able to run completely through.
    One more thing: keep an eye out on the graphic symbol's looping in the properties - you may want to set it to either play once or looping (or even single frame).
    For more info on graphic symbols, read this:
    http://dev.tutsplus.com/articles/flashs-underrated-graphic-symbol--active-9964
    Also check out those two sites' other tools. And check out the workflow on the electric Dreams website. Hope this helps a bit.

  • Creating a card dealing animation - Need a little help with the Math

    Hi Guys,
    This isn't a Java specific query per se but your advice would be greatly appreciated in order to add animation to Java card game I've developed.
    If I've posted this in the wrong forum, please let me know and I'll re-post it elsewhere.
    What I am trying to achieve is card dealing animation whereby a card is show moving from the deck position to its final position.
    The trouble I am having is how to achieve the path from where the card is dealt from to its final dealt position.
    Could somebody please point me to the right Math?
    A visual representation of what I am trying to achieve is at the below link:
    http://img266.imageshack.us/img266/3235/exampleg.jpg
    The black square represents the deck. The red square represents where the next card is dealt to with an animation showing the card leaving the deck and following a specific path to its final position in one of the red squares.
    Any advice would be appreciated.
    Edited by: Faz_86 on Jun 20, 2010 2:46 PM

    If you make a mathematically clean even animation from point A to point B, it looks artificial. Our brains are designed to spot tiny details. You can see this in the development of (hand-drawn) animation: early cartoons looked too smooth; later (by the 30's I think) animators learned tricks to make things seem more realistic or at least visually engaging.
    So if you look at the frames of a character moving, sometimes the first frame in the movement goes in the opposite direction of the larger motion. I believe you'd want something like this when the action is supposed to be driven by a conscious mind, as opposed to, say, a physics simulation.
    Applying this... if you're dealing cards, maybe the cards will leave the deck first moving in the opposite direction for a couple frames, then going in the correct direction, to make it look like a dealer is moving them. I'm just brainstorming ideas here.
    If you get a book on traditional animation techniques, it'll probably have some good ideas.

  • HDTV Input lag question

    im planning on buying an led hdtv for my xbox 360.
    But will there be input lag? the hdtv supports 720/1080i/1080p and so does the xbox 360, so there is no input lag, correct?

    in other words, can you confirm this?
    "Modern game consoles such as the 360 or PS3 don't have this problem since they are all natively HDTV ready supporting 720p, however games in 480i need to be scaled up to 720p and the rendered on the TV, during this can cause a delay, and thus what you control can have a delay on reaction times, such as your character moving a split second later then the actual input itself. This is why there is Game Mode included on certain models of HDTV, to reduce this input lag."

  • Touch Movement Angle Issue

    I'm currently developing a game for the iPhone and the first thing I did was prototype it in Flash in order to get my head round the physics of the game. In flash I managed to get a character moving round the screen using a 'brushing' movement, i.e. for the iPhone stroking the screen in the appropriate direction in order to get the character to move. Repeating this interaction in XCode hasn't been an issue as I have managed to get the character moving around the screen using these kind of movements. However I'm having an absolute nightmare with calculating the angles. Copying the same calculations across from flash has the character moving in opposite or sometimes seemingly random directions around the screen. I have attempted inverting certain variables in order to recreate the desired effects but to no avail.
    I have posted the code below, this version being the exact code I converted from flash. Any help on the matter would be greatly appreciated. Thanks.
    #import "FunView.h"
    @implementation FunView
    @synthesize ball;
    -(void)awakeFromNib {
    [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
    [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer2) userInfo:nil repeats:YES];
    pos = CGPointMake(5.0,5.0);
    pos3 = CGPointMake(5.0,0.0);
    counting = false;
    goal.center = CGPointMake(160,10);
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchCoordinates = [touch locationInView:self];
    theX1 = touchCoordinates.x;
    theY1 = touchCoordinates.y;
    xTouch1.text = [NSString stringWithFormat:@"%d", theX1];
    yTouch1.text = [NSString stringWithFormat:@"%d", theY1];
    counting = true;
    pushTimer = 0;
    UpDown.text = @"down";
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchCoordinates = [touch locationInView:self];
    theX2 = touchCoordinates.x;
    theY2 = touchCoordinates.y;
    UpDown.text = @"up";
    distanceX = (theX1 - theX2);
    distanceY = (theY1 - theY2)*-1;
    distance = sqrt(distanceX * distanceX + distanceY * distanceY);
    speed = ((distance/pushTimer))/100;
    angle = atan(distanceX/(distanceY))/(3.1415/180);
    if(distanceX < 0) {
    angle += 180;
    if (distanceX >= 0 && distanceY < 0) {
    angle += 360;
    radians = angle * (3.1415/180);
    radiansText.text = [NSString stringWithFormat:@"%f", radians];
    angleText.text = [NSString stringWithFormat:@"%f", angle];
    counting = false;
    -(void)onTimer {
    if(counting == true){
    pushTimer += 0.1;
    pushTimerText.text = [NSString stringWithFormat:@"%f", pushTimer];
    -(void)onTimer2 {
    if(gk.center.x < 90){
    pos3.x = pos3.x*-1;
    if(gk.center.x > 220){
    pos3.x = -pos3.x;
    gk.center = CGPointMake(gk.center.x + pos3.x, gk.center.y + pos3.y);
    ball.center = CGPointMake(ball.center.x + pos.x, ball.center.y + pos.y);
    if(ball.center.x > 320 || ball.center.x < 0) {
    pos.x = -pos.x;
    if(ball.center.y > 460 || ball.center.y < 0) {
    pos.y = -pos.y;
    if(speed > 1){
    xVel = cos(radians) * speed;
    yVel = sin(radians) * speed;
    pos2.x = xVel;
    pos2.y = yVel*-1;
    man.center = CGPointMake(man.center.x + pos2.x, man.center.y + pos2.y);
    speed -= 1;
    xTouch2.text = [NSString stringWithFormat:@"%d", theX2];
    yTouch2.text = [NSString stringWithFormat:@"%d", theY2];
    distanceXText.text = [NSString stringWithFormat:@"%d", distanceX];
    distanceYText.text = [NSString stringWithFormat:@"%d", distanceY];
    distanceText.text = [NSString stringWithFormat:@"%d", distance];
    speedText.text = [NSString stringWithFormat:@"%f", speed];
    xVelText.text = [NSString stringWithFormat:@"%f", xVel];
    yVelText.text = [NSString stringWithFormat:@"%f", yVel];
    @end

    Hi, PotAs & welcome to the forums.
    Just a quick tip. You may attract more code assistance if you note the alert/tip on the top of the forum as you come in that contains instructions on how to format code within a post without it being mangled on the backend. Works especially well with longer blocks/snippets, etc.
    Good luck w/your project and here's hoping it works out well.

  • Points and discussion about the concepts behind making a 2D game

    Hi all. I'm currently trying my hand at a 2D RPG style game. I have a few questions open for discussion, however, regarding the general points of implementation behind it.
    1. Tiles vs static background argument aside, am I right in the thinking the best way of implementing movement across a big background map is actually to move the background and other sprites in relation to the player, giving the illusion of player movement although he in fact never moves from the center of the screen? Is there a way of actually creating a large map, populating it with sprites, and then moving the player across it and panning the screen after him?
    2. Collision detection. If we go with the idea of moving everything in relation to the player rather than the player himself, woudln't this mean a large amount of calculations when collision detection occurs. Example, u want the player to stop moving when he hits a brick wall so you have to tell every entity sprite to stop moving in response to key presses (because remember, pressing up moves everything else up, not the player character).
    3. Isometric. Is the easiest way of implementing an isometric style game just to develop isometric graphics and sprites?
    4. Tiles. I've been doing a lot of reading into tiles but I'm not sure what's a better implementation: a tile system which consists of the entire background and things like houses split into tiles or a simple big background which can be scrolled around and is populated by house sprites which are all moved in relation to the player and their collision detections done individually. Tiles certainly seem like a nice innovation but I feel like the graphics suffer as a consequence and u end up with a 8bit NES looking game!
    I'm just getting to grips with the concepts behind a lot of game design and all of this are some interesting points which I thought would be insightful to discuss. Opinions please!
    Cheers.

    Everything I'm about to say is based off of a tile-based Maze game I made.
    1. Using a big background map is a bit lazy if you ask me, but graphically it would be easier to create a nice-looking game. You also have to think about memory. Let's say you manage to get an 800x600 background image at the size of 200kb with JPEG compression. That 200kb jpg image you use as a background is not 200kb when loaded into memory. I dont remember exactly how much bigger it gets in memory, so this next statement is probably wrong. But I heard that: 4bytes per pixel for the ARGB data, and there are 800x600 (480,000) pixels. That's 480000*4 (1920000) bytes if that statement is right. But it's probably wrong, so hopefully Abuse or someone will correct it :)
    2. Move EVERYTHING up? I think you're a little mixed up. When the background (and all objects with it) is scrolled, their actual X,Y data is not changed. It is simply drawn according to the scroll offset. The only thing that is being calclulated for movement is the character/scroll offset. Think of it as a camera. The entire world is not moving, just the location of where you're viewing it. Quick example:
    You have a Tree who's location is (10,10). If the scroll offset is (0,0), then that Tree will be drawn at (10,10). But let's say your character moves up 5 pixels. You say you want him centered, so the scroll offset also moves up 5 pixels, making the offset (0,-5). When it's time to draw again, that Tree can't be at the same place it was, because the character moved. If the character moved up, the Tree would appear as if it moved DOWN. So you'd draw it like:
    g.drawImage(tree.getImage(),tree.x-scrollOffsetX,tree.y-scrollOffsetY,null);With that math, the Tree is actually drawn at (10,15), which is lower than before the character moved. You don't actually loop through all of your objects and change each and every X and Y value, you just change the global scroll offset
    Speaking of collision detection, this is where TileMaps have a large advantage. In a TileMap, you don't have to check through each and every object in the world for collision. You can just grab the 4 surrounding tiles (north,west,east,south) from the Tile array. This means there are only 4 collision detections no matter where the character is in any situation on the map.
    If you used an image for background instead of tiles, you'd have to check each object in the world for collision because it's harder to tell how close it is to the character. One thing you could do is just grab all of the object currently visible on screen and check their collision, but, depending on where you are on the map, this could easily cause an inconsistent frame rate (you could be in a field of grass that has no collision or a forest of 50 trees each screen- LOTS of collision!).
    3. I dont got much to say about isometric :P
    4. an 8bit NES game, eh? That is the common misconception that you have to use images that are the same size of the tiles. Have you seen the game "The Legend of Zelda: Four Swords"? That's a tile-based game, but on several occasions you see trees that are 10 times bigger than the 20x20 tiles. They mixed it up, they used a TileMap for the basic ground, and put good looking large images on top. The large images (such as a large tree) uses 4 or 5 "base" tiles that are used for collision. That way the character will only collide with the bottom-half of the tree, giving the appearance of going "behind" the tree when the Y value is above the middle line of the tree. This is far away from looking like an 8bit NES game :)
    I hope that was more helpful than it was confusing, but I tend to babble, so.. anyway. Hope it helps :o

  • Vox Proxy?

    Vox Proxy is a PowerPoint add-in which brings in animated, talking figures.  The powerpoint, when imported to Captivate doesn't seem to play.  Anybody have any experience getting Ginger Rodgers and Fred Astair to dance together?

    Hi again
    Actually, I'm aware of a way to get it into Captivate.
    Vox Proxy simply uses Microsoft Agents to do what it does. I have used a similar product called MASH (Microsoft Agent Scripting Helper) so I'm a bit familiar with the characters and what is required.
    Here's a way to coax things into Captivate. It will require a bit of experimentation to achieve, but may be done.
    Many folks think of Powerpoint and Captivate and only conclude that they may Import the PowerPoint into Captivate. What they usually don't think of is the fact that PowerPoint may also be configured to display in a window. You may then launch Captivate and use it to record the PowerPoint as it plays. This should also capture the Vox Proxy character moving around too. What I'm unsure about at this point is if you readjust PowerPoint to play in a window if (or how much) it may affect the Vox Proxy character.
    Note that you will probably need to record using the Full Motion Capture method. So I hope the presentation is reasonably short.
    Let me know if you achieve success! Rick
    Click here for Adobe Certified Captivate and RoboHelp HTML Training
    Click here for the SorcerStone Blog
    Click here for RoboHelp and Captivate eBooks

Maybe you are looking for