Skip to: Site menu | Main content


Welcome to PSP-Programming.com, a place for developers to get together.

Welcome to the forums. Here you can find other user tutorials as well as homebrew releases and the source code repository. You can also ask for help with your code here and post your own homebrew!

PSP-Programming.com Forums
March 17, 2010, 08:30:35 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: Join our IRC channel: ##psp-programming on freenode
Home Help Search Shop Login Register
Digg This!
Pages: [1]
Print
Author Topic: Actionscript help(noob here).  (Read 3216 times)
DiabloTerrorGF
Full Member
***

Karma: +0/-11
Offline Offline

Posts: 101
637.80 points

View Inventory
Send Money to DiabloTerrorGF


View Profile
« on: October 20, 2006, 02:11:15 AM »

I need to change
Code:
if (Key.isDown(90))

Into a function for the mouse key.


Code:
function atcEffect()
{
    var _loc2 = _root;
    var _loc3 = this;
    for (i = 0; i < efNo1; i++)
    {
        ix = _loc2.getDeep();
        var _loc1 = "ef" + ix;
        _loc2.attachMovie("mainChar_effect", _loc1, ix + 1000);
        _loc2[_loc1]._x = _loc3._x;
        _loc2[_loc1]._y = _loc3._y;
        _loc2[_loc1]._xscale = _loc2[_loc1]._yscale = Math.random() * 40 + 20;
        _loc2[_loc1].speedX = Math.random() * 30 - 15;
        _loc2[_loc1].speedY = Math.random() * 30 - 15;
    } // end of for
} // End of the function
function Move()
{
    var _loc1 = this;
    if (Key.isDown(keyMoveUp))
    {
        if (_loc1._y > 0)
        {
            _loc1._y = _loc1._y + -nMove;
        } // end if
    } // end if
    if (Key.isDown(KeyMoveDown))
    {
        if (_loc1._y < 500)
        {
            _loc1._y = _loc1._y + nMove;
        } // end if
    } // end if
    if (Key.isDown(KeyMoveRight))
    {
        if (_loc1._x < 450)
        {
            _loc1.c.moveAction("right");
            _loc1._x = _loc1._x + nMove;
        } // end if
    } // end if
    if (Key.isDown(KeyMoveLeft))
    {
        if (_loc1._x > 0)
        {
            _loc1.c.moveAction("left");
            _loc1._x = _loc1._x + -nMove;
        } // end if
    } // end if
} // End of the function
function hitCheck()
{
    var _loc1 = this;
    if (_root.area_shot.hitTest(_loc1._x, _loc1._y + 10, true))
    {
        _loc1.atcEffect();
        _loc1.c._name = null;
        lifeMode = 0;
        hitMode = 0;
        _loc1.gotoAndPlay("hit");
    } // end if
} // End of the function
efNo1 = 20;
lifeMode = 1;
hitMode = 0;
mySound = new Sound(this);
keyMoveUp = 38;
keyMoveDown = 40;
keyMoveRight = 39;
keyMoveLeft = 37;
baseMove = 6;
this.onEnterFrame = function ()
{
    var _loc1 = this;
    if (lifeMode == 1)
    {
        _loc1.Move();
        if (Key.isDown(90))
        {
            nMove = baseMove / 2;
            _loc1.gotoAndStop("shot");
        }
        else
        {
            nMove = baseMove;
            _loc1.gotoAndStop("normal");
        } // end else if
        if (Key.isDown(88))
        {
            _root.display.bomber();
        } // end if
        if (_currentframe < 25 && hitMode == 1)
        {
            _loc1.hitCheck();
        } // end if
    } // end if
};



I tried this but I am total nub at flash(just trying to convert my favorite game to PSP use-able-ness) and the z key is shoot, trying to make mouse key shoot :/

Code:
function atcEffect()
{
    var _loc2 = _root;
    var _loc3 = this;
    for (i = 0; i < efNo1; i++)
    {
        ix = _loc2.getDeep();
        var _loc1 = "ef" + ix;
        _loc2.attachMovie("mainChar_effect", _loc1, ix + 1000);
        _loc2[_loc1]._x = _loc3._x;
        _loc2[_loc1]._y = _loc3._y;
        _loc2[_loc1]._xscale = _loc2[_loc1]._yscale = Math.random() * 40 + 20;
        _loc2[_loc1].speedX = Math.random() * 30 - 15;
        _loc2[_loc1].speedY = Math.random() * 30 - 15;
    } // end of for
} // End of the function
function Move()
{
    var _loc1 = this;
    if (Key.isDown(keyMoveUp))
    {
        if (_loc1._y > 0)
        {
            _loc1._y = _loc1._y + -nMove;
        } // end if
    } // end if
    if (Key.isDown(KeyMoveDown))
    {
        if (_loc1._y < 500)
        {
            _loc1._y = _loc1._y + nMove;
        } // end if
    } // end if
    if (Key.isDown(KeyMoveRight))
    {
        if (_loc1._x < 450)
        {
            _loc1.c.moveAction("right");
            _loc1._x = _loc1._x + nMove;
        } // end if
    } // end if
    if (Key.isDown(KeyMoveLeft))
    {
        if (_loc1._x > 0)
        {
            _loc1.c.moveAction("left");
            _loc1._x = _loc1._x + -nMove;
        } // end if
    } // end if
} // End of the function
function hitCheck()
{
    var _loc1 = this;
    if (_root.area_shot.hitTest(_loc1._x, _loc1._y + 10, true))
    {
        _loc1.atcEffect();
        _loc1.c._name = null;
        lifeMode = 0;
        hitMode = 0;
        _loc1.gotoAndPlay("hit");
    } // end if
} // End of the function
efNo1 = 20;
lifeMode = 1;
hitMode = 0;
mySound = new Sound(this);
keyMoveUp = 38;
keyMoveDown = 40;
keyMoveRight = 39;
keyMoveLeft = 37;
baseMove = 6;
shotthing = 0;
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
shotthing = 1;
}
mouseListener.onMouseUp = function() {
shotthing = 0;
}
Mouse.addListener(mouseListener);
this.onEnterFrame = function ()
{



    var _loc1 = this;
    if (lifeMode == 1)
    {
        _loc1.Move();
        if (shotthing == 1)
        {
            nMove = baseMove / 2;
            _loc1.gotoAndStop("shot");
        }
        else
        {
            nMove = baseMove;
            _loc1.gotoAndStop("normal");
        } // end else if
        if (Key.isDown(88))
        {
            _root.display.bomber();
        } // end if
        if (_currentframe < 25 && hitMode == 1)
        {
            _loc1.hitCheck();
        } // end if
    } // end if
};

Logged


nathan42100
Give miinaturvat Points!
Administrator
Hero Member
*

Karma: +31/-2
Offline Offline

Posts: 1158
804.49 points

View Inventory
Send Money to nathan42100


View Profile WWW
« Reply #1 on: October 20, 2006, 11:02:25 AM »

How about:
if (Key.isDown(90))
{
 mouseFunction();
}
function mouseFunction
{
 ...do this...
}
Logged

All of my work is released under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
dn ʎɐʍ sıɥʇ
Help support my computer projects!

DiabloTerrorGF
Full Member
***

Karma: +0/-11
Offline Offline

Posts: 101
637.80 points

View Inventory
Send Money to DiabloTerrorGF


View Profile
« Reply #2 on: October 20, 2006, 08:26:02 PM »

Got it to work using this:
Code:
_global.shotthing = 0;
Mouse.addListener (Mouse);
Mouse.onMouseDown = function () {_global.shotthing = 1; };
Mouse.onMouseUp = function () { _global.shotthing = 0; };


And it runs at an amazing 10 fps <_<


http://www.freewebs.com/diabloterrorgf/bs.swf

Average 11 fps.

D-pad to move, X to fire your laser and since I had no more buttons left, when you let go of your first shot, it will use a "bomb."

And it wouldn't be right of me to not include the original .swf place:
http://nextframe.jp/index.html

I love that site and just trying to make some of the flash files work for psp.
Logged
bernardy25
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 3
205.63 points

View Inventory
Send Money to bernardy25

View Profile
« Reply #3 on: December 16, 2009, 04:27:55 AM »

I had similar situation and I like to tell you that it works properly for me.
Logged

Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.196 seconds with 28 queries.
Sister Sites: Guitar Hero 4   BrokeniTouch.com