How to make a sprite move?

Discussion in 'iOS Programming' started by MrPenguin9, Oct 26, 2008.

  1. MrPenguin9 macrumors member

    Joined:
    Aug 1, 2008
    #1
    Hi, I am new to programing for the iPhone(I bought my mac yesterday). I want to make a simple game where there is a button "Right" and a button "Left", and when you press the button the sprite moves. And when you let go of the button, the sprite stops moving. And I can't figure out how to make the sprite move.

    Thanks so much
     
  2. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    Have you looked at Apple's sample code in the dev center? There seem to be several animation app examples for you to study.


    .
     
  3. admanimal macrumors 68040

    Joined:
    Apr 22, 2005
  4. MrPenguin9 thread starter macrumors member

    Joined:
    Aug 1, 2008
    #4
    Yes I have gone through it and I found "CGAffineTransformMakeTranslation" but it doesn't tell me how to use it.:(
     
  5. MrPenguin9 thread starter macrumors member

    Joined:
    Aug 1, 2008
    #5
    What do you think I'm trying to do? Get some common sense.
     
  6. admanimal macrumors 68040

    Joined:
    Apr 22, 2005
    #6
    If you've never programmed anything before, the best way to start learning is not to come in and specifically ask how to achieve effect X. You need to learn some fundamentals so you don't have to keep asking when you want to do Y or Z.

    What you are trying to do is very simple and should not be difficult to figure out by reading through Apple's documentation and doing some objective-C tutorials. It may be painful at first but in the long run you'll be better off.
     
  7. lawicko macrumors member

    Joined:
    Jul 17, 2008
    #7
    If you have never programmed in objective C before I'd suggest beginning with something easier, for example simple hello world with one button etc. Knowing the syntax, delegation and other fundamentals will really help you to improve fast, no point in creating more difficult app on the very beginning.
     
  8. MrPenguin9 thread starter macrumors member

    Joined:
    Aug 1, 2008
    #8
    >_> I have done a hello word tutorial and a couple of other. But I can't find one about movement.
     
  9. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #9
    movement is not a good thing to start with in an oop language. That being said, check out http://www.appsamuck.com/day17.html for a simple movement example, with downloadable source code. Check out their homepage, www.appsamuck.com, for a total of 15 short useful examples so far, they're trying to get to 31.
     
  10. Niiro13 macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #10
    That is because movement is slightly more advanced.

    You have to use the CGAffineTransformMakeTranslation and apply it to your object's transform property.
     
  11. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008

Share This Page