• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

convert a dragged item (mouseX + x) to tactical screen

Contributor ,
Aug 11, 2013 Aug 11, 2013

Copy link to clipboard

Copied

I'm making a game in AS3 (point & click). I would like to do it for PC and for tablets. But, I've got a problem:

In my Pc version, when I go to the inventory and click on an item, the item will replace my cursor and I can dragg it where I went on the screen.

In my tactical version, when I click on the item, it will get stuck on the left corner of the screen. I suppose that the problem is that is no cursor in a tactical version..

Do you know what do I have to change for the tactical version ? (for exemple, the item stay in the middle off the screen and I have to click where I want it to be, no draging.

Thank you for your help,

Here is my code for my "dragItem" function :

    public function DraggedItem(stageRef:Stage, grabbedItem:Object){

        this.stageRef = stageRef;

        toolbar = Engine.toolbar;

        usableItems = Engine.usableItems;

        inv = Engine.inv;

        puzzle = Engine.puzzle;

        player = Engine.player;

        linesData = Engine.linesData;

        inv.draggingItem = true;

        Mouse.hide();

        itemRef = getDefinitionByName(grabbedItem.displayName.toLowerCase()+"Proper");

        draggedItem = new itemRef;

        stageRef.addChild(draggedItem);

        draggedItem.displayName = grabbedItem.displayName;

        if (grabbedItem.lookTag)

            draggedItem.lookTag = grabbedItem.lookTag;

        draggedItem.x = mouseX + x;

        draggedItem.y = mouseY + y;

        draggedItem.scaleX = itemScale;

        draggedItem.scaleY = itemScale;

        stageRef.addEventListener(MouseEvent.MOUSE_MOVE, dragItem, false, 0, true);

        stageRef.addEventListener(Event.ENTER_FRAME, itemHitTest, false, 0, true);

        draggedItem.addEventListener(MouseEvent.CLICK, itemClick, false, 0, true);

    }

    private function dragItem(e:MouseEvent):void{

        draggedItem.x = mouseX + x;

        draggedItem.y = mouseY + y;

    }

TOPICS
ActionScript

Views

3.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 11, 2013 Aug 11, 2013

what's mouseX when that code executes?  ie, mouseX probably's not defined when that code executes.

Votes

Translate

Translate
Contributor ,
Sep 11, 2013 Sep 11, 2013

Copy link to clipboard

Copied

You're right ! It works on the mobile !!!! THX !!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2013 Sep 11, 2013

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines